error.mx raw
1 package cm
2
3 import "unsafe"
4
5 // ErrorContext represents the Component Model [error-context] type,
6 // an immutable, non-deterministic, host-defined value meant to aid in debugging.
7 //
8 // [error-context]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md#error-context-type
9 type ErrorContext struct {
10 _ HostLayout
11 errorContext
12 }
13
14 type errorContext uint32
15
16 // Error implements the [error] interface. It returns the debug message associated with err.
17 func (err errorContext) Error() string {
18 return err.DebugMessage()
19 }
20
21 // String implements [fmt.Stringer].
22 func (err errorContext) String() string {
23 return err.DebugMessage()
24 }
25
26 // DebugMessage represents the Canonical ABI [error-context.debug-message] function.
27 //
28 // [error-context.debug-message]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md#error-contextdebug-message
29 func (err errorContext) DebugMessage() []byte {
30 var s []byte
31 wasmimport_errorContextDebugMessage(err, unsafe.Pointer(&s))
32 return s
33 }
34
35 // Drop represents the Canonical ABI [error-context.drop] function.
36 //
37 // [error-context.drop]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md#error-contextdrop
38 func (err errorContext) Drop() {
39 wasmimport_errorContextDrop(err)
40 }
41