Skip to content
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

Merged

Conversation

danieleformichelli
Copy link
Collaborator

In case of an error there, tuist was crashing without providing any error

@danieleformichelli danieleformichelli force-pushed the feature/improve-error-message-modulemepmapper branch from 2403b0a to 2d6431d Compare November 26, 2021 08:55
Copy link
Contributor

@pepicrft pepicrft left a 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): \
Copy link
Contributor

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):
Copy link
Contributor

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
Copy link
Member

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.

Copy link
Collaborator Author

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 {
Copy link
Member

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?

@danieleformichelli danieleformichelli merged commit 69d6a87 into main Nov 26, 2021
@danieleformichelli danieleformichelli deleted the feature/improve-error-message-modulemepmapper branch November 26, 2021 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants