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

@ -31,7 +31,7 @@ class StringsFileGenerator {
try fileContent.write(to: stringsFilePathURL, atomically: false, encoding: .utf8)
} catch (let error) {
let error = StringiumError.writeFile(error.localizedDescription, stringsFilePath)
print(error.localizedDescription)
print(error.description)
Stringium.exit(withError: error)
}
}
@ -75,7 +75,7 @@ class StringsFileGenerator {
stringsFileContent += "\"\(definition.name)\" = \"\(translation)\";\n\n"
} else if skipDefinition == false {
let error = StringiumError.langNotDefined(lang, definition.name, definition.reference != nil)
print(error.localizedDescription)
print(error.description)
Stringium.exit(withError: error)
}
}
@ -101,7 +101,7 @@ class StringsFileGenerator {
try extensionFileContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
} catch (let error) {
let error = StringiumError.writeFile(extensionFilePath, error.localizedDescription)
print(error.localizedDescription)
print(error.description)
Stringium.exit(withError: error)
}
}

View File

@ -24,7 +24,7 @@ class TagsGenerator {
try extensionFileContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
} catch (let error) {
let error = StringiumError.writeFile(extensionFilePath, error.localizedDescription)
print(error.localizedDescription)
print(error.description)
Stringium.exit(withError: error)
}
}

View File

@ -109,7 +109,7 @@ class Definition {
func getNSLocalizedStringProperty(forLang lang: String) -> String {
guard let translation = translations[lang] else {
let error = StringiumError.langNotDefined(lang, name, reference != nil)
print(error.localizedDescription)
print(error.description)
Stringium.exit(withError: error)
}
@ -132,7 +132,7 @@ class Definition {
func getNSLocalizedStringStaticProperty(forLang lang: String) -> String {
guard let translation = translations[lang] else {
let error = StringiumError.langNotDefined(lang, name, reference != nil)
print(error.localizedDescription)
print(error.description)
Stringium.exit(withError: error)
}
@ -157,7 +157,7 @@ class Definition {
func getProperty(forLang lang: String) -> String {
guard let translation = translations[lang] else {
let error = StringiumError.langNotDefined(lang, name, reference != nil)
print(error.localizedDescription)
print(error.description)
Stringium.exit(withError: error)
}
@ -173,7 +173,7 @@ class Definition {
func getStaticProperty(forLang lang: String) -> String {
guard let translation = translations[lang] else {
let error = StringiumError.langNotDefined(lang, name, reference != nil)
print(error.localizedDescription)
print(error.description)
Stringium.exit(withError: error)
}

View File

@ -84,7 +84,7 @@ class TwineFileParser {
}
}
if invalidDefinitionNames.count > 0 {
print(" warning:[\(Stringium.toolName)] Found \(invalidDefinitionNames.count) definition (\(invalidDefinitionNames.joined(separator: ", "))")
print("warning: [\(Stringium.toolName)] Found \(invalidDefinitionNames.count) definition (\(invalidDefinitionNames.joined(separator: ", "))")
}
return sections

View File

@ -70,20 +70,20 @@ struct Stringium: ParsableCommand {
// Input file
guard fileManager.fileExists(atPath: options.inputFile) else {
let error = StringiumError.fileNotExists(options.inputFile)
print(error.localizedDescription)
print(error.description)
Stringium.exit(withError: error)
}
// Langs
guard options.langs.isEmpty == false else {
let error = StringiumError.langsListEmpty
print(error.localizedDescription)
print(error.description)
Stringium.exit(withError: error)
}
guard options.langs.contains(options.defaultLang) else {
let error = StringiumError.defaultLangsNotInLangs
print(error.localizedDescription)
print(error.description)
Stringium.exit(withError: error)
}

View File

@ -17,22 +17,22 @@ enum StringiumError: Error {
var localizedDescription: String {
switch self {
case .fileNotExists(let filename):
return " error:[\(Stringium.toolName)] File \(filename) does not exists "
return "error: [\(Stringium.toolName)] File \(filename) does not exists "
case .langsListEmpty:
return " error:[\(Stringium.toolName)] Langs list is empty"
return "error: [\(Stringium.toolName)] Langs list is empty"
case .defaultLangsNotInLangs:
return " error:[\(Stringium.toolName)] Langs list does not contains the default lang"
return "error: [\(Stringium.toolName)] Langs list does not contains the default lang"
case .writeFile(let subErrorDescription, let filename):
return " error:[\(Stringium.toolName)] An error occured while writing content to \(filename): \(subErrorDescription)"
return "error: [\(Stringium.toolName)] An error occured while writing content to \(filename): \(subErrorDescription)"
case .langNotDefined(let lang, let definitionName, let isReference):
if isReference {
return " error:[\(Stringium.toolName)] Reference are handled only by TwineTool. Please use it or remove reference from you strings file."
return "error: [\(Stringium.toolName)] Reference are handled only by Twine. Please use it or remove reference from you strings file."
}
return " error:[\(Stringium.toolName)] Lang \"\(lang)\" not found for \"\(definitionName)\""
return "error: [\(Stringium.toolName)] Lang \"\(lang)\" not found for \"\(definitionName)\""
}
}
}

View File

@ -62,7 +62,7 @@ struct Tags: ParsableCommand {
// Input file
guard fileManager.fileExists(atPath: options.inputFile) else {
let error = StringiumError.fileNotExists(options.inputFile)
print(error.localizedDescription)
print(error.description)
Stringium.exit(withError: error)
}

View File

@ -66,20 +66,20 @@ struct Twine: ParsableCommand {
// Input file
guard fileManager.fileExists(atPath: options.inputFile) else {
let error = TwineError.fileNotExists(options.inputFile)
print(error.localizedDescription)
print(error.description)
Twine.exit(withError: error)
}
// Langs
guard options.langs.isEmpty == false else {
let error = TwineError.langsListEmpty
print(error.localizedDescription)
print(error.description)
Twine.exit(withError: error)
}
guard options.langs.contains(options.defaultLang) else {
let error = TwineError.defaultLangsNotInLangs
print(error.localizedDescription)
print(error.description)
Twine.exit(withError: error)
}

View File

@ -15,13 +15,13 @@ enum TwineError: Error {
var localizedDescription: String {
switch self {
case .fileNotExists(let filename):
return " error:[\(Twine.toolName)] File \(filename) does not exists "
return "error: [\(Twine.toolName)] File \(filename) does not exists "
case .langsListEmpty:
return " error:[\(Twine.toolName)] Langs list is empty"
return "error: [\(Twine.toolName)] Langs list is empty"
case .defaultLangsNotInLangs:
return " error:[\(Twine.toolName)] Langs list does not contains the default lang"
return "error: [\(Twine.toolName)] Langs list does not contains the default lang"
}
}
}