Update AppError.swift

This commit is contained in:
Jungpyo Hong 2021-05-19 23:17:13 -05:00 committed by GitHub
parent eb5ed75ae1
commit 9d1f2af3f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,33 +5,56 @@
// //
// Created by JungpyoHong on 5/4/21. // Created by JungpyoHong on 5/4/21.
// //
import Foundation import Foundation
enum AppError: Error { enum AppError: Error {
case badUrl case badUrl
case badResponse
case serverError case serverError
case badResponse
case noData case noData
case parseError case parseError
case badRequest case badRequest
case genericError(String) case genericError(String)
case parametersNil
case encodingFail
case unauthorizedLocationAccess
case copyError
var errorMessage: String { var errorMessage: String {
switch self { switch self {
case .badUrl: case .badUrl:
return "" return "URL is not valid"
case .badResponse:
return ""
case .serverError: case .serverError:
return "" return "Server Error"
case .badResponse:
return "Bad HTTP response"
case .noData: case .noData:
return "" return "No data found"
case .badRequest:
return ""
case .parseError: case .parseError:
return "" return "Parsing Error"
case .badRequest:
return "Bad Request"
case .genericError(let message): case .genericError(let message):
return message return message
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"
} }
} }
} }