github.com/bananabytelabs/wazero@v0.0.0-20240105073314-54b22a776da8/internal/wasmruntime/errors.go (about) 1 // Package wasmruntime contains internal symbols shared between modules for error handling. 2 // Note: This is named wasmruntime to avoid conflicts with the normal go module. 3 // Note: This only imports "api" as importing "wasm" would create a cyclic dependency. 4 package wasmruntime 5 6 var ( 7 // ErrRuntimeStackOverflow indicates that there are too many function calls, 8 // and the Engine terminated the execution. 9 ErrRuntimeStackOverflow = New("stack overflow") 10 // ErrRuntimeInvalidConversionToInteger indicates the Wasm function tries to 11 // convert NaN floating point value to integers during trunc variant instructions. 12 ErrRuntimeInvalidConversionToInteger = New("invalid conversion to integer") 13 // ErrRuntimeIntegerOverflow indicates that an integer arithmetic resulted in 14 // overflow value. For example, when the program tried to truncate a float value 15 // which doesn't fit in the range of target integer. 16 ErrRuntimeIntegerOverflow = New("integer overflow") 17 // ErrRuntimeIntegerDivideByZero indicates that an integer div or rem instructions 18 // was executed with 0 as the divisor. 19 ErrRuntimeIntegerDivideByZero = New("integer divide by zero") 20 // ErrRuntimeUnreachable means "unreachable" instruction was executed by the program. 21 ErrRuntimeUnreachable = New("unreachable") 22 // ErrRuntimeOutOfBoundsMemoryAccess indicates that the program tried to access the 23 // region beyond the linear memory. 24 ErrRuntimeOutOfBoundsMemoryAccess = New("out of bounds memory access") 25 // ErrRuntimeInvalidTableAccess means either offset to the table was out of bounds of table, or 26 // the target element in the table was uninitialized during call_indirect instruction. 27 ErrRuntimeInvalidTableAccess = New("invalid table access") 28 // ErrRuntimeIndirectCallTypeMismatch indicates that the type check failed during call_indirect. 29 ErrRuntimeIndirectCallTypeMismatch = New("indirect call type mismatch") 30 ) 31 32 // Error is returned by a wasm.Engine during the execution of Wasm functions, and they indicate that the Wasm runtime 33 // state is unrecoverable. 34 type Error struct { 35 s string 36 } 37 38 func New(text string) *Error { 39 return &Error{s: text} 40 } 41 42 func (e *Error) Error() string { 43 return e.s 44 }