Skip to content

Commit

Permalink
Replace all fatalError with error logging (#295)
Browse files Browse the repository at this point in the history
* Replace all fatalError with error logging

* Fix default error param
  • Loading branch information
neakor authored and rudro committed May 14, 2019
1 parent 162813c commit dfa6cc7
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class DependencyGraphExporter {
} else if currentTask is DependencyProviderSerializerTask, let serializedProviders = currentResult as? [SerializedProvider] {
return .endOfSequence(serializedProviders)
} else {
fatalError("Unhandled task \(currentTask) with result \(currentResult)")
error("Unhandled task \(currentTask) with result \(currentResult)")
}
}
taskHandleTuples.append((taskHandle, component.name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class PluginizedDependencyGraphExporter {
} else if currentTask is PluginizedDependencyProviderSerializerTask, let serializedProviders = currentResult as? [SerializedProvider] {
return .endOfSequence(serializedProviders)
} else {
fatalError("Unhandled task \(currentTask) with result \(currentResult)")
error("Unhandled task \(currentTask) with result \(currentResult)")
}
}
taskHandleTuples.append((taskHandle, component.name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class AbstractDependencyGraphParser {
} else if currentTask is ComponentExtensionsParserTask, let node = currentResult as? ComponentExtensionNode {
return .endOfSequence(node)
} else {
fatalError("Unhandled task \(currentTask) with result \(currentResult)")
error("Unhandled task \(currentTask) with result \(currentResult)")
}
}
}
Expand Down Expand Up @@ -174,7 +174,7 @@ class AbstractDependencyGraphParser {
return .endOfSequence(nil)
}
} else {
fatalError("Unhandled task \(currentTask) with result \(currentResult)")
error("Unhandled task \(currentTask) with result \(currentResult)")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class DependencyGraphParser: AbstractDependencyGraphParser {
} else if currentTask is DeclarationsParserTask, let node = currentResult as? DependencyGraphNode {
return .endOfSequence(node)
} else {
fatalError("Unhandled task \(currentTask) with result \(currentResult)")
error("Unhandled task \(currentTask) with result \(currentResult)")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class PluginizedDependencyGraphParser: AbstractDependencyGraphParser {
} else if currentTask is PluginizedDeclarationsParserTask, let node = currentResult as? PluginizedDependencyGraphNode {
return .endOfSequence(node)
} else {
fatalError("Unhandled task \(currentTask) with result \(currentResult)")
error("Unhandled task \(currentTask) with result \(currentResult)")
}
}

Expand Down
10 changes: 5 additions & 5 deletions Generator/Sources/needle/GenerateCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ class GenerateCommand: AbstractCommand {
do {
try generator.generate(from: sourceRootPaths, withSourcesListFormat: sourcesListFormat, excludingFilesEndingWith: excludeSuffixes, excludingFilesWithPaths: excludePaths, with: additionalImports, headerDocPath, to: destinationPath, shouldCollectParsingInfo: shouldCollectParsingInfo, parsingTimeout: parsingTimeout, exportingTimeout: exportingTimeout, retryParsingOnTimeoutLimit: retryParsingOnTimeoutLimit, concurrencyLimit: concurrencyLimit)
} catch GenericError.withMessage(let message) {
fatalError(message)
} catch {
fatalError("Unknown error: \(error)")
error(message)
} catch (let e) {
error("Unknown error: \(e)")
}
} else {
fatalError("Missing source files root directories.")
error("Missing source files root directories.")
}
} else {
fatalError("Missing destination path.")
error("Missing destination path.")
}
}

Expand Down
8 changes: 4 additions & 4 deletions Generator/Sources/needle/PrintDependencyTreeCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ class PrintDependencyTreeCommand: AbstractCommand {
do {
try generator.printDependencyTree(from: sourceRootPaths, withSourcesListFormat: sourcesListFormat, excludingFilesEndingWith: excludeSuffixes, excludingFilesWithPaths: excludePaths, shouldCollectParsingInfo: shouldCollectParsingInfo, parsingTimeout: parsingTimeout, retryParsingOnTimeoutLimit: retryParsingOnTimeoutLimit, concurrencyLimit: concurrencyLimit, rootComponentName: rootComponentName)
} catch GenericError.withMessage(let message) {
fatalError(message)
} catch {
fatalError("Unknown error: \(error)")
error(message)
} catch (let e) {
error("Unknown error: \(e)")
}
} else {
fatalError("Missing source files root directories.")
error("Missing source files root directories.")
}
}

Expand Down
5 changes: 3 additions & 2 deletions Generator/Sources/needle/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Basic
import CommandFramework
import Foundation
import NeedleFramework
import SourceParsingFramework
import SPMUtility

func main() {
Expand All @@ -27,8 +28,8 @@ func main() {
do {
let args = try parser.parse(inputs)
execute(commands, with: parser, args)
} catch {
fatalError("Command-line pasing error (use --help for help): \(error)")
} catch (let e) {
error("Command-line pasing error (use --help for help): \(e)")
}
}

Expand Down

0 comments on commit dfa6cc7

Please sign in to comment.