From f6765d5f34ff49ccc921f214a8af17de6064f9b8 Mon Sep 17 00:00:00 2001 From: Aotokitsuruya Date: Thu, 15 Aug 2024 18:16:28 +0800 Subject: [PATCH] Update error message to use mrb.Raisef --- class.go | 4 ++-- vm.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/class.go b/class.go index 8aaf0a1..2089444 100644 --- a/class.go +++ b/class.go @@ -115,12 +115,12 @@ func (mrb *State) vmDefineClass(outer Value, super Value, id Symbol) (RClass, er if ClassP(super) { superClass = super.(RClass) } else { - panic("super is not a class") + mrb.Raisef(nil, "superclass must be a Class (%T given)", super) } } if !ClassPointerP(outer) { - panic("outer is not a class or module") + mrb.Raisef(nil, "outer is not a class or module") } outerModule := outer.(RClass) diff --git a/vm.go b/vm.go index b760c75..4e18546 100644 --- a/vm.go +++ b/vm.go @@ -346,7 +346,7 @@ func (mrb *State) VmExec(proc RProc, code *insn.Sequence) (ret Value, err error) recv, ok := ctx.Get(int(a)).(RClass) if !ok { - panic(fmt.Errorf("not a class: %v", ctx.Get(int(a)))) + mrb.Raisef(nil, "not a class: %v", ctx.Get(int(a))) } nirep := rep.Representation(b)