MCPcopy Create free account
hub / github.com/buke/quickjs-go / ThrowTypeError

Method ThrowTypeError

context.go:1199–1207  ·  view source on GitHub ↗

ThrowTypeError returns a context's exception value with given error message.

(format string, args ...interface{})

Source from the content-addressed store, hash-verified

1197
1198// ThrowTypeError returns a context's exception value with given error message.
1199func (ctx *Context) ThrowTypeError(format string, args ...interface{}) *Value {
1200 if !ctx.hasValidRef() {
1201 return nil
1202 }
1203 cause := fmt.Sprintf(format, args...)
1204 causePtr := C.CString(cause)
1205 defer C.free(unsafe.Pointer(causePtr))
1206 return &Value{ctx: ctx, ref: C.ThrowTypeError(ctx.ref, causePtr)}
1207}
1208
1209// ThrowReferenceError returns a context's exception value with given error message.
1210func (ctx *Context) ThrowReferenceError(format string, args ...interface{}) *Value {

Calls 1

hasValidRefMethod · 0.95