@@ -193,7 +193,10 @@ public func readConfiguration(string: String, configPath: URL?, file: String = #
193193 decoder. allowsJSON5 = true
194194 return try decoder. decode ( Configuration . self, from: configData)
195195 } catch {
196- throw ConfigurationError ( message: " Failed to parse SwiftJava configuration at ' \( configPath. map ( { $0. absoluteURL. description } ) ?? " <no-path> " ) '! \( #fileID) : \( #line) " , error: error,
196+ throw ConfigurationError (
197+ message: " Failed to parse SwiftJava configuration at ' \( configPath. map ( { $0. absoluteURL. description } ) ?? " <no-path> " ) '! \( #fileID) : \( #line) " ,
198+ error: error,
199+ text: string,
197200 file: file, line: line)
198201 }
199202}
@@ -286,31 +289,37 @@ extension Configuration {
286289public struct ConfigurationError : Error {
287290 let message : String
288291 let error : any Error
292+ let text : String ?
289293
290294 let file : String
291295 let line : UInt
292296
293- init ( message: String , error: any Error , file: String = #fileID, line: UInt = #line) {
297+ init ( message: String , error: any Error , text : String ? , file: String = #fileID, line: UInt = #line) {
294298 self . message = message
295299 self . error = error
300+ self . text = text
296301 self . file = file
297302 self . line = line
298303 }
299304}
300305
301- public enum LogLevel : String , Codable , Hashable {
306+ public enum LogLevel : String , ExpressibleByStringLiteral , Codable , Hashable {
302307 case trace = " trace "
303308 case debug = " debug "
304309 case info = " info "
305310 case notice = " notice "
306311 case warning = " warning "
307312 case error = " error "
308313 case critical = " critical "
314+
315+ public init ( stringLiteral value: String ) {
316+ self = LogLevel ( rawValue: value) ?? . info
317+ }
309318}
310319
311320extension LogLevel {
312321 public init ( from decoder: any Decoder ) throws {
313- var container = try decoder. unkeyedContainer ( )
322+ var container = try decoder. singleValueContainer ( )
314323 let string = try container. decode ( String . self)
315324 switch string {
316325 case " trace " : self = . trace
0 commit comments