File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,13 @@ extension APIRequest {
26
26
public static func send< Result> ( uRLRequest: URLRequest , with session: URLSession ) async throws -> APIResponse < Result > {
27
27
let ( data, response) = try await session. data ( for: uRLRequest)
28
28
29
- guard 200 ..< 400 ~= response. statusCode else { throw Web3Error . serverError ( code: response. statusCode) }
29
+ guard 200 ..< 400 ~= response. statusCode else {
30
+ if 400 ..< 500 ~= response. statusCode {
31
+ throw Web3Error . clientError ( code: response. statusCode)
32
+ } else {
33
+ throw Web3Error . serverError ( code: response. statusCode)
34
+ }
35
+ }
30
36
31
37
/// This bit of code is purposed to work with literal types that comes in Response in hexString type.
32
38
/// Currently it's just `Data` and any kind of Integers `(U)Int`, `Big(U)Int`.
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ public enum Web3Error: Error {
15
15
case typeError
16
16
case valueError
17
17
case serverError( code: Int )
18
+ case clientError( code: Int )
18
19
19
20
case walletError
20
21
case inputError( desc: String )
@@ -52,6 +53,8 @@ public enum Web3Error: Error {
52
53
return " Unsupported type "
53
54
case let . serverError( code: code) :
54
55
return " Server error: \( code) "
56
+ case let . clientError( code: code) :
57
+ return " Client error: \( code) "
55
58
case . valueError:
56
59
return " You're passing value that doesn't supported by this method. "
57
60
}
You can’t perform that action at this time.
0 commit comments