Skip to content

Commit 622c972

Browse files
committed
Change order in which components of errors are printed.
1 parent 47291bd commit 622c972

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

Sources/LispKit/Compiler/RuntimeError.swift

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,23 +192,17 @@ public class RuntimeError: Error, Hashable, CustomStringConvertible {
192192

193193
public func printableDescription(typeOpen: String = "[",
194194
typeClose: String = "] ",
195-
positionHeader: String? = "\nat: ",
196195
irritantHeader: String? = "\nirritants: ",
197196
irritantSeparator: String = ", ",
197+
positionHeader: String? = "\nat: ",
198198
stackTraceHeader: String? = "\nstack trace: ",
199199
stackTraceSeparator: String = ", ") -> String {
200200
var usedIrritants = Set<Int>()
201201
let message = self.replacePlaceholders(in: self.descriptor.messageTemplate,
202202
with: self.irritants,
203203
recordingUsage: &usedIrritants)
204-
let position: String
205-
if let positionHeader = positionHeader, !self.pos.isUnknown {
206-
position = positionHeader + self.pos.description
207-
} else {
208-
position = ""
209-
}
210204
var builder = StringBuilder(
211-
prefix: "\(typeOpen)\(self.descriptor.typeDescription)\(typeClose)\(message)\(position)",
205+
prefix: "\(typeOpen)\(self.descriptor.typeDescription)\(typeClose)\(message)",
212206
postfix: "",
213207
separator: irritantSeparator,
214208
initial: irritantHeader ?? "")
@@ -219,6 +213,9 @@ public class RuntimeError: Error, Hashable, CustomStringConvertible {
219213
}
220214
}
221215
}
216+
if let positionHeader = positionHeader, !self.pos.isUnknown {
217+
builder.append(positionHeader + self.pos.description)
218+
}
222219
if let stackTraceHeader = stackTraceHeader,
223220
let stackTrace = self.stackTrace {
224221
builder = StringBuilder(prefix: builder.description,

0 commit comments

Comments
 (0)