File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -25,8 +25,10 @@ final class Serializer: Sendable {
25
25
26
26
/// Decodes JSON data into a specified `Decodable` type.
27
27
/// - Parameter data: The JSON data to decode.
28
- /// - Throws: `VRCKitError.apiError` if the decoded data contains an API error.
29
- /// - Throws: `DecodingError` if the decoding process fails.
28
+ /// - Throws:
29
+ /// - `VRCKitError.unauthorized` if the decoded data contains an unauthentized error.
30
+ /// - `VRCKitError.apiError` if the decoded data contains an API error.
31
+ /// - `DecodingError` if the decoding process fails.
30
32
/// - Returns: The decoded object of type `T`.
31
33
func decode< T> ( _ data: Data ) throws -> T where T: Decodable {
32
34
do {
@@ -35,15 +37,11 @@ final class Serializer: Sendable {
35
37
do {
36
38
let errorResponse = try decoder. decode ( ErrorResponse . self, from: data)
37
39
if errorResponse. error. statusCode == 401 {
38
- throw VRCKitError . credentialNotSet
40
+ throw VRCKitError . unauthorized
39
41
} else {
40
42
throw VRCKitError . apiError ( errorResponse. error. message)
41
43
}
42
44
} catch _ as DecodingError {
43
- // for debug
44
- print ( type ( of: T . self) )
45
- print ( error)
46
- print ( String ( data: data, encoding: . utf8) ?? " " )
47
45
throw error
48
46
}
49
47
}
You can’t perform that action at this time.
0 commit comments