-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathDiagnosticError.swift
More file actions
38 lines (31 loc) · 935 Bytes
/
DiagnosticError.swift
File metadata and controls
38 lines (31 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// DiagnosticError.swift
// TophatFoundation
//
// Created by Lukas Romsicki on 2026-03-11.
// Copyright © 2026 Shopify. All rights reserved.
//
import Foundation
/// The type you use to wrap an error in order to provide additional technical details
/// for debugging purposes.
public struct DiagnosticError: Error {
/// The error to present to the user.
public let error: Error
/// A technical description of the underlying cause.
public let technicalDetails: String?
public init(_ error: Error, technicalDetails: String? = nil) {
self.error = error
self.technicalDetails = technicalDetails
}
}
extension DiagnosticError: LocalizedError {
public var errorDescription: String? {
(error as? LocalizedError)?.errorDescription
}
public var failureReason: String? {
(error as? LocalizedError)?.failureReason
}
public var recoverySuggestion: String? {
(error as? LocalizedError)?.recoverySuggestion
}
}