Skip to content

Commit 7c88c46

Browse files
committed
fix: unauthorized error
1 parent f383f65 commit 7c88c46

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Sources/VRCKit/Utils/Serializer.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ final class Serializer: Sendable {
2525

2626
/// Decodes JSON data into a specified `Decodable` type.
2727
/// - 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.
3032
/// - Returns: The decoded object of type `T`.
3133
func decode<T>(_ data: Data) throws -> T where T: Decodable {
3234
do {
@@ -35,15 +37,11 @@ final class Serializer: Sendable {
3537
do {
3638
let errorResponse = try decoder.decode(ErrorResponse.self, from: data)
3739
if errorResponse.error.statusCode == 401 {
38-
throw VRCKitError.credentialNotSet
40+
throw VRCKitError.unauthorized
3941
} else {
4042
throw VRCKitError.apiError(errorResponse.error.message)
4143
}
4244
} catch _ as DecodingError {
43-
// for debug
44-
print(type(of: T.self))
45-
print(error)
46-
print(String(data: data, encoding: .utf8) ?? "")
4745
throw error
4846
}
4947
}

0 commit comments

Comments
 (0)