-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathhresult.go
79 lines (71 loc) · 3.46 KB
/
hresult.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
package d3d
/*
Contains common D3D11 / DXGI errorcodes and allows to use them as Go errors
*/
//go:generate stringer -type=HRESULT -output=hresult_string.go
import (
"strconv"
"strings"
)
type HRESULT uint32
func (hr HRESULT) Failed() bool {
return int32(hr) < 0
}
const (
S_OK HRESULT = 0x0
E_INVALIDARG HRESULT = 0x80070057
DXGI_STATUS_OCCLUDED HRESULT = 0x087A0001
DXGI_STATUS_CLIPPED HRESULT = 0x087A0002
DXGI_STATUS_NO_REDIRECTION HRESULT = 0x087A0004
DXGI_STATUS_NO_DESKTOP_ACCESS HRESULT = 0x087A0005
DXGI_STATUS_GRAPHICS_VIDPN_SOURCE_IN_USE HRESULT = 0x087A0006
DXGI_STATUS_MODE_CHANGED HRESULT = 0x087A0007
DXGI_STATUS_MODE_CHANGE_IN_PROGRESS HRESULT = 0x087A0008
DXGI_ERROR_INVALID_CALL HRESULT = 0x887A0001
DXGI_ERROR_NOT_FOUND HRESULT = 0x887A0002
DXGI_ERROR_MORE_DATA HRESULT = 0x887A0003
DXGI_ERROR_UNSUPPORTED HRESULT = 0x887A0004
DXGI_ERROR_DEVICE_REMOVED HRESULT = 0x887A0005
DXGI_ERROR_DEVICE_HUNG HRESULT = 0x887A0006
DXGI_ERROR_DEVICE_RESET HRESULT = 0x887A0007
DXGI_ERROR_WAS_STILL_DRAWING HRESULT = 0x887A000A
DXGI_ERROR_FRAME_STATISTICS_DISJOINT HRESULT = 0x887A000B
DXGI_ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE HRESULT = 0x887A000C
DXGI_ERROR_DRIVER_INTERNAL_ERROR HRESULT = 0x887A0020
DXGI_ERROR_NONEXCLUSIVE HRESULT = 0x887A0021
DXGI_ERROR_NOT_CURRENTLY_AVAILABLE HRESULT = 0x887A0022
DXGI_ERROR_REMOTE_CLIENT_DISCONNECTED HRESULT = 0x887A0023
DXGI_ERROR_REMOTE_OUTOFMEMORY HRESULT = 0x887A0024
DXGI_ERROR_ACCESS_LOST HRESULT = 0x887A0026
DXGI_ERROR_WAIT_TIMEOUT HRESULT = 0x887A0027
DXGI_ERROR_SESSION_DISCONNECTED HRESULT = 0x887A0028
DXGI_ERROR_RESTRICT_TO_OUTPUT_STALE HRESULT = 0x887A0029
DXGI_ERROR_CANNOT_PROTECT_CONTENT HRESULT = 0x887A002A
DXGI_ERROR_ACCESS_DENIED HRESULT = 0x887A002B
DXGI_ERROR_NAME_ALREADY_EXISTS HRESULT = 0x887A002C
DXGI_ERROR_SDK_COMPONENT_MISSING HRESULT = 0x887A002D
DXGI_ERROR_NOT_CURRENT HRESULT = 0x887A002E
DXGI_ERROR_HW_PROTECTION_OUTOFMEMORY HRESULT = 0x887A0030
DXGI_ERROR_DYNAMIC_CODE_POLICY_VIOLATION HRESULT = 0x887A0031
DXGI_ERROR_NON_COMPOSITED_UI HRESULT = 0x887A0032
DXGI_STATUS_UNOCCLUDED HRESULT = 0x087A0009
DXGI_STATUS_DDA_WAS_STILL_DRAWING HRESULT = 0x087A000A
DXGI_ERROR_MODE_CHANGE_IN_PROGRESS HRESULT = 0x887A0025
DXGI_STATUS_PRESENT_REQUIRED HRESULT = 0x087A002F
DXGI_ERROR_CACHE_CORRUPT HRESULT = 0x887A0033
DXGI_ERROR_CACHE_FULL HRESULT = 0x887A0034
DXGI_ERROR_CACHE_HASH_COLLISION HRESULT = 0x887A0035
DXGI_ERROR_ALREADY_EXISTS HRESULT = 0x887A0036
DXGI_DDI_ERR_WASSTILLDRAWING HRESULT = 0x887B0001
DXGI_DDI_ERR_UNSUPPORTED HRESULT = 0x887B0002
DXGI_DDI_ERR_NONEXCLUSIVE HRESULT = 0x887B0003
)
func (e HRESULT) Error() string {
str := e.String()
if strings.HasSuffix(str, ")") {
// Workaround: return just the hex code as error if no name found
return "0x" + strconv.FormatUint(uint64(e), 16)
}
// return name and hex value
return str + " (0x" + strconv.FormatUint(uint64(e), 16) + ")"
}