Issue #704
We used to declare enum that conforms to Error
, but any type like struct or class can conform to Error as well.
enum NetworkError: Error {
case failToCreateRequest
case failToParseResponse
case failToReachServe
}
struct DetailError: Error {
let networkError: Error
let createdAt: Date
let tag: String
}
final class TrackError: Error {
let trackId: String
let detailError: DetailError
let trackSession: String
init(trackId: String, detailError: DetailError, trackSession: String) {
self.trackId = trackId
self.detailError = detailError
self.trackSession = trackSession
}
}
let networkError = NetworkError.failToCreateRequest
let detailError = DetailError(networkError: networkError, createdAt: Date(), tag: "0.1")
let trackError = TrackError(trackId: "AB-01", detailError: detailError, trackSession: "101")