@@ -42,8 +42,23 @@ public func legacyLog<T>(instance: T, name: String, id: Int, startLine: Int, end
42
42
do {
43
43
data = try packet. encode ( )
44
44
}
45
+ catch LoggingError . failedToGenerateOpaqueRepresentation {
46
+ fatalError ( " Failures to generate opaque representations should not occur during encoding " )
47
+ }
48
+ catch let LoggingError . encodingFailure( reason) {
49
+ let errorPacket = LogPacket ( errorWithReason: reason, startLine: startLine, endLine: endLine, startColumn: startColumn, endColumn: endColumn, threadID: packet. threadID)
50
+
51
+ // Encoding an error packet should not fail under any circumstances.
52
+ data = try ! errorPacket. encode ( )
53
+ }
54
+ catch let LoggingError . otherFailure( reason) {
55
+ let errorPacket = LogPacket ( errorWithReason: reason, startLine: startLine, endLine: endLine, startColumn: startColumn, endColumn: endColumn, threadID: packet. threadID)
56
+
57
+ // Encoding an error packet should not fail under any circumstances.
58
+ data = try ! errorPacket. encode ( )
59
+ }
45
60
catch {
46
- let errorPacket = LogPacket ( errorWithReason: " Error occurred while encoding log packet" , startLine: startLine, endLine: endLine, startColumn: startColumn, endColumn: endColumn, threadID: packet. threadID)
61
+ let errorPacket = LogPacket ( errorWithReason: " Unknown failure encoding log packet" , startLine: startLine, endLine: endLine, startColumn: startColumn, endColumn: endColumn, threadID: packet. threadID)
47
62
48
63
// Encoding an error packet should not fail under any circumstances.
49
64
data = try ! errorPacket. encode ( )
@@ -84,8 +99,23 @@ func legacyLogPostPrint(startLine: Int, endLine: Int, startColumn: Int, endColum
84
99
do {
85
100
data = try packet. encode ( )
86
101
}
102
+ catch LoggingError . failedToGenerateOpaqueRepresentation {
103
+ fatalError ( " Failures to generate opaque representations should not occur during encoding " )
104
+ }
105
+ catch let LoggingError . encodingFailure( reason) {
106
+ let errorPacket = LogPacket ( errorWithReason: reason, startLine: startLine, endLine: endLine, startColumn: startColumn, endColumn: endColumn, threadID: packet. threadID)
107
+
108
+ // Encoding an error packet should not fail under any circumstances.
109
+ data = try ! errorPacket. encode ( )
110
+ }
111
+ catch let LoggingError . otherFailure( reason) {
112
+ let errorPacket = LogPacket ( errorWithReason: reason, startLine: startLine, endLine: endLine, startColumn: startColumn, endColumn: endColumn, threadID: packet. threadID)
113
+
114
+ // Encoding an error packet should not fail under any circumstances.
115
+ data = try ! errorPacket. encode ( )
116
+ }
87
117
catch {
88
- let errorPacket = LogPacket ( errorWithReason: " Error occurred while encoding log packet" , startLine: startLine, endLine: endLine, startColumn: startColumn, endColumn: endColumn, threadID: packet. threadID)
118
+ let errorPacket = LogPacket ( errorWithReason: " Unknown failure encoding log packet" , startLine: startLine, endLine: endLine, startColumn: startColumn, endColumn: endColumn, threadID: packet. threadID)
89
119
90
120
// Encoding an error packet should not fail under any circumstances.
91
121
data = try ! errorPacket. encode ( )
0 commit comments