-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathstatus.go
96 lines (87 loc) · 3.12 KB
/
status.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package napi
/*
#include <node/node_api.h>
*/
import "C"
import (
"fmt"
)
type Status int
type StatusError Status
var _ error = StatusError(0)
const (
StatusOK Status = C.napi_ok
StatusInvalidArg Status = C.napi_invalid_arg
StatusObjectExpected Status = C.napi_object_expected
StatusStringExpected Status = C.napi_string_expected
StatusNameExpected Status = C.napi_name_expected
StatusFunctionExpected Status = C.napi_function_expected
StatusNumberExpected Status = C.napi_number_expected
StatusBooleanExpected Status = C.napi_boolean_expected
StatusArrayExpected Status = C.napi_array_expected
StatusGenericFailure Status = C.napi_generic_failure
StatusPendingException Status = C.napi_pending_exception
StatusCancelled Status = C.napi_cancelled
StatusEscapeCalledTwice Status = C.napi_escape_called_twice
StatusHandleScopeMismatch Status = C.napi_handle_scope_mismatch
StatusCallbackScopeMismatch Status = C.napi_callback_scope_mismatch
StatusQueueFull Status = C.napi_queue_full
StatusClosing Status = C.napi_closing
StatusBigintExpected Status = C.napi_bigint_expected
StatusDateExpected Status = C.napi_date_expected
StatusArraybufferExpected Status = C.napi_arraybuffer_expected
StatusDetachableArraybufferExpected Status = C.napi_detachable_arraybuffer_expected
StatusWouldDeadlock Status = C.napi_would_deadlock
)
func (s Status) String() string {
switch s {
case StatusOK:
return "napi_ok"
case StatusInvalidArg:
return "napi_invalid_arg"
case StatusObjectExpected:
return "napi_object_expected"
case StatusStringExpected:
return "napi_string_expected"
case StatusNameExpected:
return "napi_name_expected"
case StatusFunctionExpected:
return "napi_function_expected"
case StatusNumberExpected:
return "napi_number_expected"
case StatusBooleanExpected:
return "napi_boolean_expected"
case StatusArrayExpected:
return "napi_array_expected"
case StatusGenericFailure:
return "napi_generic_failure"
case StatusPendingException:
return "napi_pending_exception"
case StatusCancelled:
return "napi_cancelled"
case StatusEscapeCalledTwice:
return "napi_escape_called_twice"
case StatusHandleScopeMismatch:
return "napi_handle_scope_mismatch"
case StatusCallbackScopeMismatch:
return "napi_callback_scope_mismatch"
case StatusQueueFull:
return "napi_queue_full"
case StatusClosing:
return "napi_closing"
case StatusBigintExpected:
return "napi_bigint_expected"
case StatusDateExpected:
return "napi_date_expected"
case StatusArraybufferExpected:
return "napi_arraybuffer_expected"
case StatusDetachableArraybufferExpected:
return "napi_detachable_arraybuffer_expected"
case StatusWouldDeadlock:
return "napi_would_deadlock"
}
return "napi_go_status_unknown"
}
func (err StatusError) Error() string {
return fmt.Sprintf("napi_status error: %s", Status(err))
}