Skip to content

Commit

Permalink
Set up the error handler before running the command
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Piñera committed Jul 17, 2019
1 parent 0db37d3 commit 906f1c7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 1 addition & 5 deletions Sources/TuistCore/Errors/ErrorHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,9 @@ public final class ErrorHandler: ErrorHandling {
public func setup() throws {
#if canImport(Sentry)
if !isDisabled(), !sentryDsn.isEmpty {
Client.logLevel = .none
Client.shared = try Client(dsn: sentryDsn)
try Client.shared?.startCrashHandler()

// Report unhandled exceptions
NSSetUncaughtExceptionHandler { _ in
exit(1)
}
}
#endif
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/TuistEnvKit/Commands/CommandRegistry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public final class CommandRegistry {
// MARK: - Public

public func run(file: StaticString = #file, line: UInt = #line) {
try? errorHandler.setup()

do {
if processArguments().dropFirst().first == "--help-env" {
parser.printUsage(on: stdoutStream)
Expand Down
2 changes: 2 additions & 0 deletions Sources/TuistKit/Commands/CommandRegistry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public final class CommandRegistry {
// MARK: - Public

public func run(file: StaticString = #file, line: UInt = #line) {
try? errorHandler.setup()

do {
// Hidden command
if let hiddenCommand = hiddenCommand() {
Expand Down

0 comments on commit 906f1c7

Please sign in to comment.