-
-
Notifications
You must be signed in to change notification settings - Fork 583
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
feat: improve error message of ModuleMapMapper #3733
feat: improve error message of ModuleMapMapper #3733
Conversation
2403b0a
to
2d6431d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for improving this @danyf90. Providing good error messages is strongly connected to the developers' experience.
switch self { | ||
case let .invalidTargetDependency(sourceProject, sourceTarget, dependentTarget): | ||
return """ | ||
Invalid target dependency for target \(sourceTarget) of project at path \(sourceProject.pathString): \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick:
Target A of the project at path X depends on a target B that can't be found
Do we know why that might be the case? If so, we can add an extra sentence hinting to the users what might be the issue.
Invalid target dependency for target \(sourceTarget) of project at path \(sourceProject.pathString): \ | ||
can't find target '\(dependentTarget)' | ||
""" | ||
case let .invalidProjectTargetDependency(sourceProject, sourceTarget, dependentProject, dependentTarget): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment here. If we can provide hints on why it happened, I'd add them. Otherwise, we can leave it as it is.
/// Error type. | ||
var type: ErrorType { | ||
switch self { | ||
case .invalidTargetDependency, .invalidProjectTargetDependency: return .abort |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this misconfiguration on the user side? If it's due to how we handle SPM dependencies from Dependencies.swift
, I'd mark this as bug
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be both, so I would go with abort
@@ -107,16 +138,33 @@ public final class ModuleMapMapper: WorkspaceMapping { | |||
let dependentTarget: Target | |||
switch dependency { | |||
case let .target(name): | |||
guard let dependentTargetFromName = targetsByName[name] else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be worth making a test for whether the errors are actually thrown?
In case of an error there, tuist was crashing without providing any error