@@ -9,105 +9,86 @@ struct GraphQLTransportWSError: Error {
99 self . code = code
1010 }
1111
12- static func unauthorized ( ) -> Self {
12+ static func forbidden ( ) -> Self {
1313 return self . init (
14- " Unauthorized " ,
15- code: . unauthorized
14+ " Forbidden " ,
15+ code: . forbidden
1616 )
1717 }
1818
1919 static func notInitialized( ) -> Self {
2020 return self . init (
2121 " Connection not initialized " ,
22- code: . notInitialized
22+ code: . unauthorized
2323 )
2424 }
2525
2626 static func tooManyInitializations( ) -> Self {
2727 return self . init (
2828 " Too many initialisation requests " ,
29- code: . tooManyInitializations
29+ code: . tooManyRequests
3030 )
3131 }
3232
3333 static func subscriberAlreadyExists( id: String ) -> Self {
3434 return self . init (
3535 " Subscriber for \( id) already exists " ,
36- code: . subscriberAlreadyExists
36+ code: . conflict
3737 )
3838 }
3939
4040 static func invalidEncoding( ) -> Self {
4141 return self . init (
4242 " Message was not encoded in UTF8 " ,
43- code: . invalidEncoding
43+ code: . miscellaneous
4444 )
4545 }
4646
4747 static func noType( ) -> Self {
4848 return self . init (
4949 " Message has no 'type' field " ,
50- code: . noType
50+ code: . miscellaneous
5151 )
5252 }
5353
5454 static func invalidType( ) -> Self {
5555 return self . init (
5656 " Message 'type' value does not match supported types " ,
57- code: . invalidType
57+ code: . miscellaneous
5858 )
5959 }
6060
6161 static func invalidRequestFormat( messageType: RequestMessageType ) -> Self {
6262 return self . init (
6363 " Request message doesn't match ' \( messageType. type. rawValue) ' JSON format " ,
64- code: . invalidRequestFormat
64+ code: . miscellaneous
6565 )
6666 }
6767
6868 static func invalidResponseFormat( messageType: ResponseMessageType ) -> Self {
6969 return self . init (
7070 " Response message doesn't match ' \( messageType. type. rawValue) ' JSON format " ,
71- code: . invalidResponseFormat
71+ code: . miscellaneous
7272 )
7373 }
7474
7575 static func internalAPIStreamIssue( errors: [ GraphQLError ] ) -> Self {
7676 return self . init (
7777 " API Response did not result in a stream type, contained errors \n \( errors. map { $0. message } . joined ( separator: " \n " ) ) " ,
78- code: . internalAPIStreamIssue
79- )
80- }
81-
82- static func graphQLError( _ error: Error ) -> Self {
83- return self . init (
84- " \( error) " ,
85- code: . graphQLError
78+ code: . internalServerError
8679 )
8780 }
8881}
8982
9083/// Error codes for miscellaneous issues
91- public enum ErrorCode : Int , CustomStringConvertible , Sendable {
84+ enum ErrorCode : Int , CustomStringConvertible , Sendable {
9285 /// Miscellaneous
9386 case miscellaneous = 4400
94-
95- // Internal errors
96- case graphQLError = 4401
97- case internalAPIStreamIssue = 4402
98-
99- // Message errors
100- case invalidEncoding = 4410
101- case noType = 4411
102- case invalidType = 4412
103- case invalidRequestFormat = 4413
104- case invalidResponseFormat = 4414
105-
106- // Initialization errors
107- case unauthorized = 4430
108- case notInitialized = 4431
109- case tooManyInitializations = 4432
110- case subscriberAlreadyExists = 4433
87+ case unauthorized = 4401
88+ case forbidden = 4403
89+ case conflict = 4409
90+ case tooManyRequests = 4429
91+ case internalServerError = 4500
11192
11293 public var description : String {
11394 return " \( rawValue) "
0 commit comments