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