Fix error/warning message to be shown in Xcode.IssueNavigator
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit

This commit is contained in:
2022-11-22 17:14:13 +01:00
parent 5a3d273acc
commit fc427733ee
27 changed files with 79 additions and 79 deletions

View File

@ -16,19 +16,19 @@ enum GenerateError: Error {
var localizedDescription: String {
switch self {
case .fileNotExists(let filename):
return " error:[\(Generate.toolName)] File \(filename) does not exists"
return "error: [\(Generate.toolName)] File \(filename) does not exists"
case .invalidConfigurationFile(let filename):
return " error:[\(Generate.toolName)] File \(filename) is not a valid configuration file"
return "error: [\(Generate.toolName)] File \(filename) is not a valid configuration file"
case .commandError(let command, let terminationStatus):
let readableCommand = command
.map { $0 }
.joined(separator: " ")
return "error:[\(Generate.toolName)] An error occured while running command '\(readableCommand)'. Command terminate with status code: \(terminationStatus)"
return "error: [\(Generate.toolName)] An error occured while running command '\(readableCommand)'. Command terminate with status code: \(terminationStatus)"
case .writeFile(let filename, let info):
return "error:[\(Generate.toolName)] An error occured while writing file in \(filename): \(info)"
return "error: [\(Generate.toolName)] An error occured while writing file in \(filename): \(info)"
}
}
}

View File

@ -20,7 +20,7 @@ struct ArchitectureGenerator {
let filename = "\(architecture.classname).swift"
guard let filePath = architecture.path else {
let error = GenerateError.writeFile(filename, "Path of file is not defined.")
print(error.localizedDescription)
print(error.description)
Generate.exit(withError: error)
}
@ -30,7 +30,7 @@ struct ArchitectureGenerator {
try architectureContent.write(to: architectureFilePathURL, atomically: false, encoding: .utf8)
} catch (let error) {
let error = GenerateError.writeFile(filename, error.localizedDescription)
print(error.localizedDescription)
print(error.description)
Generate.exit(withError: error)
}
}

View File

@ -12,13 +12,13 @@ class ConfigurationFileParser {
static func parse(_ configurationFile: String) -> ConfigurationFile {
guard let data = FileManager().contents(atPath: configurationFile) else {
let error = GenerateError.fileNotExists(configurationFile)
print(error.localizedDescription)
print(error.description)
Generate.exit(withError: error)
}
guard let configuration = try? YAMLDecoder().decode(ConfigurationFile.self, from: data) else {
let error = GenerateError.invalidConfigurationFile(configurationFile)
print(error.localizedDescription)
print(error.description)
Generate.exit(withError: error)
}