Conformed the AmiiboServiceError error in the library target to the LocalizedError protocol.
This commit is contained in:
@@ -1,17 +1,19 @@
|
|||||||
// ===----------------------------------------------------------------------===
|
// ===----------------------------------------------------------------------===
|
||||||
//
|
//
|
||||||
// This source file is part of the Amiibo Service open source project
|
// This source file is part of the Amiibo Service open source project
|
||||||
//
|
//
|
||||||
// Copyright (c) 2026 Röck+Cöde VoF. and the Amiibo Service project authors
|
// Copyright (c) 2026 Röck+Cöde VoF. and the Amiibo Service project authors
|
||||||
// Licensed under Apache license v2.0
|
// Licensed under Apache license v2.0
|
||||||
//
|
//
|
||||||
// See LICENSE for license information
|
// See LICENSE for license information
|
||||||
// See CONTRIBUTORS for the list of Amiibo Service project authors
|
// See CONTRIBUTORS for the list of Amiibo Service project authors
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
//
|
//
|
||||||
// ===----------------------------------------------------------------------===
|
// ===----------------------------------------------------------------------===
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
/// A representation of all the possible errors that the ``AmiiboService`` service could throw.
|
/// A representation of all the possible errors that the ``AmiiboService`` service could throw.
|
||||||
public enum AmiiboServiceError: Error {
|
public enum AmiiboServiceError: Error {
|
||||||
/// The request was malformed or contained invalid filter parameters.
|
/// The request was malformed or contained invalid filter parameters.
|
||||||
@@ -33,3 +35,23 @@ public enum AmiiboServiceError: Error {
|
|||||||
// MARK: - Equatable
|
// MARK: - Equatable
|
||||||
|
|
||||||
extension AmiiboServiceError: Equatable {}
|
extension AmiiboServiceError: Equatable {}
|
||||||
|
|
||||||
|
// MARK: - LocalizedError
|
||||||
|
|
||||||
|
extension AmiiboServiceError: LocalizedError {
|
||||||
|
|
||||||
|
// MARK: Properties
|
||||||
|
|
||||||
|
public var errorDescription: String? {
|
||||||
|
switch self {
|
||||||
|
case .badRequest: "The request was malformed or contained invalid filter parameters."
|
||||||
|
case .cancelled: "The request was cancelled before a response was received."
|
||||||
|
case .decoding: "The response body could not be decoded into the expected model."
|
||||||
|
case .notAvailable: "The backend service is currently unreachable due to a network or server issue."
|
||||||
|
case .notFound: "No results were found matching the given filter criteria."
|
||||||
|
case .undocumented(let statusCode): "The server returned an undocumented HTTP status code: \(statusCode)."
|
||||||
|
case .unknown: "An unexpected error occurred."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user