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)