awesome-ios-developer/Helper/Network Layer/Error Manager/AppError.swift

61 lines
1.3 KiB
Swift
Raw Normal View History

2021-05-06 00:20:54 +07:00
//
// AppError.swift
// OperationQueueDemo
//
// Created by JungpyoHong on 5/4/21.
//
2021-05-20 11:17:13 +07:00
2021-05-06 00:20:54 +07:00
import Foundation
enum AppError: Error {
case badUrl
case serverError
2021-05-20 11:17:13 +07:00
case badResponse
2021-05-06 00:20:54 +07:00
case noData
case parseError
case badRequest
case genericError(String)
2021-05-20 11:17:13 +07:00
case parametersNil
case encodingFail
case unauthorizedLocationAccess
case copyError
2021-05-06 00:20:54 +07:00
var errorMessage: String {
switch self {
case .badUrl:
2021-05-20 11:17:13 +07:00
return "URL is not valid"
2021-05-06 00:20:54 +07:00
case .serverError:
2021-05-20 11:17:13 +07:00
return "Server Error"
case .badResponse:
return "Bad HTTP response"
2021-05-06 00:20:54 +07:00
case .noData:
2021-05-20 11:17:13 +07:00
return "No data found"
2021-05-06 00:20:54 +07:00
case .parseError:
2021-05-20 11:17:13 +07:00
return "Parsing Error"
case .badRequest:
return "Bad Request"
2021-05-06 00:20:54 +07:00
case .genericError(let message):
return message
2021-05-20 11:17:13 +07:00
case .parametersNil:
return "Parameters were nil."
case .encodingFail:
return "Parameter encoding fail."
case .unauthorizedLocationAccess:
return "Unauthorized Location Access"
case .copyError:
return "Unable to copy file"
2021-05-06 00:20:54 +07:00
}
}
}
2021-05-20 11:17:13 +07:00