feat(core): add scheme error type
This commit is contained in:
1 parent
48092fe48f
commit
549631fe99
1 file changed
+19
@@ -0,0 +1,19 @@
|
|||||||
|
public struct SchemeError: Error, CustomStringConvertible {
|
||||||
|
public let message: String
|
||||||
|
public let irritants: [Value]
|
||||||
|
|
||||||
|
public init(_ message: String, irritants: [Value] = []) {
|
||||||
|
self.message = message
|
||||||
|
self.irritants = irritants
|
||||||
|
}
|
||||||
|
|
||||||
|
public var description: String {
|
||||||
|
if irritants.isEmpty { return message }
|
||||||
|
let parts = irritants.map { writeString($0) }.joined(separator: " ")
|
||||||
|
return "\(message) \(parts)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func schemeError(_ message: String, _ irritants: [Value] = []) -> SchemeError {
|
||||||
|
SchemeError(message, irritants: irritants)
|
||||||
|
}
|
||||||
Reference in new issue
Block a user