File tree Expand file tree Collapse file tree 2 files changed +21
-7
lines changed Expand file tree Collapse file tree 2 files changed +21
-7
lines changed Original file line number Diff line number Diff line change 5
5
// Created by Alsey Coleman Miller on 10/19/18.
6
6
//
7
7
8
+ import Foundation
8
9
import CSDL2
9
10
10
11
/// SDL Error
@@ -23,6 +24,18 @@ extension SDLError: CustomStringConvertible {
23
24
}
24
25
}
25
26
27
+ extension SDLError : CustomDebugStringConvertible {
28
+
29
+ public var debugDescription : String {
30
+
31
+ var description = errorMessage
32
+ if let debugInformation = debugInformation {
33
+ description += " " + " ( \( debugInformation. description) ) "
34
+ }
35
+ return description
36
+ }
37
+ }
38
+
26
39
internal extension SDLError {
27
40
28
41
final class DebugInformation : CustomStringConvertible {
@@ -46,12 +59,10 @@ internal extension SDLError {
46
59
self . type = String ( reflecting: type)
47
60
}
48
61
49
- public lazy var description : String = {
50
-
51
- return [ file, line. description, type, function]
52
- . compactMap { $0 }
53
- . reduce ( " " ) { $0 + ( $0. isEmpty ? " " : " : " ) + $1 }
54
- } ( )
62
+ public var description : String {
63
+ let fileName = file. components ( separatedBy: " / " ) . last ?? file
64
+ return " \( fileName) : \( line. description) \( type) . \( function) "
65
+ }
55
66
}
56
67
}
57
68
Original file line number Diff line number Diff line change @@ -107,8 +107,11 @@ func main() throws {
107
107
}
108
108
109
109
do { try main ( ) }
110
+ catch let error as SDLError {
111
+ print ( " Error: \( error. debugDescription) " )
112
+ exit ( EXIT_FAILURE)
113
+ }
110
114
catch {
111
115
print ( " Error: \( error) " )
112
- dump ( error)
113
116
exit ( EXIT_FAILURE)
114
117
}
You can’t perform that action at this time.
0 commit comments