AutoCat/AutoCatCore/Services/ApiService/ApiError.swift

31 lines
752 B
Swift

//
// ApiError.swift
// AutoCatCore
//
// Created by Selim Mustafaev on 11.06.2024.
// Copyright © 2024 Selim Mustafaev. All rights reserved.
//
import Foundation
public enum ApiError: LocalizedError, Equatable {
case generic
case emptyResponse
case unauthorized
case threadSafety
case message(String)
case httpError(Int)
public var errorDescription: String? {
switch self {
case .generic: "Something went wrong"
case .emptyResponse: "Empty response"
case .unauthorized: "Unauthorized"
case .threadSafety: "Thread safety error"
case .message(let message): message
case .httpError(let status): "General http error (status \(status))"
}
}
}