Skip to content

Better error reporting #6061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

### Bug Fixes

* None.
* Improved error reporting when SwiftLint exits, because of an invalid configuration file
or other error.
[Martin Redington](https://github.com/mildm8nnered)
[#6052](https://github.com/realm/SwiftLint/issues/6052)

## 0.59.1: Crisp Spring Clean

Expand Down
6 changes: 3 additions & 3 deletions Source/SwiftLintCore/Models/Issue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public enum Issue: LocalizedError, Equatable {
}

/// The issues description which is ready to be printed to the console.
package var errorDescription: String {
public var errorDescription: String? {
switch self {
case .genericError:
return "error: \(message)"
Expand All @@ -132,8 +132,8 @@ public enum Issue: LocalizedError, Equatable {
if case .ruleDeprecated = self, !Self.printDeprecationWarnings {
return
}
Self.printQueueContinuation?.yield(errorDescription)
queuedPrintError(errorDescription)
Self.printQueueContinuation?.yield(localizedDescription)
queuedPrintError(localizedDescription)
}

private var message: String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public struct Configuration {
if useDefaultConfigOnFailure ?? !hasCustomConfigurationFiles {
// No files were explicitly specified, so maybe the user doesn't want a config at all -> warn
queuedPrintError(
"\(Issue.wrap(error: error).errorDescription) – Falling back to default configuration"
"\(Issue.wrap(error: error).localizedDescription) – Falling back to default configuration"
)
self.init(rulesMode: rulesMode, cachePath: cachePath)
} else {
Expand Down