Repository navigation
Expand file tree
/
Copy pathcode.go
More file actions
141 lines (122 loc) · 5.56 KB
/
Copy pathcode.go
File metadata and controls
141 lines (122 loc) · 5.56 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package csbgo
import "strconv"
// Code is a CSB error code.
//
// CSB reports a failure by using an escape code of the consumer protocol (HTTP
// uses 500) and embedding the real code in the description as
// "[CSB Error Code] CSB Error Message". When the failure happened at the service
// provider, the CSB escape code CodeServiceServerError (800) is used and the
// provider's own code follows: "[800][Provider Code] Provider Message".
//
// Those fields are parsed into Error.Code, Error.ProviderCode and Error.Message
// and surfaced through the *StatusError returned by Client.Do.
type Code int
// CSB error codes.
const (
CodeSuccess Code = 200
CodePlatformError Code = 500
CodeAccessDenied Code = 501
CodeSignatureVerificationError Code = 502
CodeServiceNotRegistered Code = 503
CodeAPINameNotFound Code = 504
CodeAccessKeyNotFound Code = 505
CodeSignatureNotFound Code = 506
CodeRequiredParameterMissing Code = 507
CodeSecureChannelRequired Code = 508
CodeTimestampNotFound Code = 509
CodeTimeExpired Code = 510
CodeInvokeTimeout Code = 511
CodeWriteChannelError Code = 512
CodeConnectionBroken Code = 513
CodeHSFAddressNotFound Code = 514
CodeHSFProcessError Code = 515
CodeHOHProcessError Code = 516
CodeJSONToHSFProcessError Code = 517
CodeServiceMetadataNull Code = 518
CodeBlackListDenied Code = 519
CodeServiceMetadataNotFound Code = 520
CodeIPNotInWhiteList Code = 521
CodeProtocolNotOpen Code = 522
CodeStrictAccessKeyWhiteList Code = 523
CodeAccessLimited Code = 524
// CodeServiceServerError is the CSB escape code for a failure at the
// service provider; ProviderCode then carries the provider's own code.
CodeServiceServerError Code = 800
CodeConnectToProviderError Code = 801
CodeServiceOffline Code = 802
CodeServiceStopped Code = 803
// CodeHSFEscape is the escape code of the HSF consumer protocol.
CodeHSFEscape Code = 99
// CodeUnknown is used by CSB when it cannot classify the failure.
CodeUnknown Code = 900
CodeBadSOAPRequest Code = 1001
CodeBadResponse Code = 1002
CodeBadHSFSubscribeInfo Code = 1003
CodeHSFInvokeException Code = 1004
CodeBadInputSOAPParsing Code = 1005
CodeBadOutputSOAPParsing Code = 1006
CodeBadInvokeRESTProvider Code = 1007
CodeBadJSONToWSRequest Code = 1008
CodeJSONToWSProcessError Code = 1009
CodeResultFilterFailed Code = 10001
)
// EscapeCodeHTTP is the escape code of the HTTP consumer protocol: a CSB stage-2
// or stage-3 failure arrives as this HTTP status, with the real code in the body.
const EscapeCodeHTTP Code = CodePlatformError
var codeText = map[Code]string{
CodeSuccess: "SUCCESS",
CodePlatformError: "platform error",
CodeAccessDenied: "access permission deny",
CodeSignatureVerificationError: "signature verification failed",
CodeServiceNotRegistered: "service not registed",
CodeAPINameNotFound: "api name not found",
CodeAccessKeyNotFound: "access key not found",
CodeSignatureNotFound: "signature not found",
CodeRequiredParameterMissing: "required parameter is missing",
CodeSecureChannelRequired: "need to access security channel",
CodeTimestampNotFound: "timestamp not found",
CodeTimeExpired: "time expired",
CodeInvokeTimeout: "invoke timeout",
CodeWriteChannelError: "write channel error",
CodeConnectionBroken: "connection has broken",
CodeHSFAddressNotFound: "hsf address not found",
CodeHSFProcessError: "hsf process error",
CodeHOHProcessError: "hoh process error",
CodeJSONToHSFProcessError: "json2hsf process error",
CodeServiceMetadataNull: "service metadata is null",
CodeBlackListDenied: "access permission deny by black list",
CodeServiceMetadataNotFound: "can not found service metadata",
CodeIPNotInWhiteList: "access permission deny, ip is not in white list",
CodeProtocolNotOpen: "this invoke protocol not open",
CodeStrictAccessKeyWhiteList: "access permission deny due to strict accesskey and ip white list",
CodeAccessLimited: "exceed access limition, try later",
CodeServiceServerError: "service server error",
CodeConnectToProviderError: "connect to service server error",
CodeServiceOffline: "serivce has offline from server",
CodeServiceStopped: "serivce has been stopped",
CodeHSFEscape: "hsf escap code",
CodeUnknown: "Unknown code",
CodeBadSOAPRequest: "bad soap request",
CodeBadResponse: "bad response",
CodeBadHSFSubscribeInfo: "bad hsf subscribe info",
CodeHSFInvokeException: "hsf invoke exception",
CodeBadInputSOAPParsing: "bad input soap parsing",
CodeBadOutputSOAPParsing: "bad output soap parsing",
CodeBadInvokeRESTProvider: "bad invoke restful provider",
CodeBadJSONToWSRequest: "json2ws process error, bad input restufl/json request",
CodeJSONToWSProcessError: "json2ws process error",
CodeResultFilterFailed: "process response result data filter failed",
}
// String returns the CSB description of the code, or "csb code N" when the code
// is not one of the documented ones.
func (c Code) String() string {
if s, ok := codeText[c]; ok {
return s
}
return "csb code " + strconv.Itoa(int(c))
}
// Known reports whether c is a documented CSB error code.
func (c Code) Known() bool {
_, ok := codeText[c]
return ok
}