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

Propagate FS errors when creating a new project #10708

Merged
merged 9 commits into from
Aug 5, 2024

Conversation

radeusgd
Copy link
Member

Pull Request Description

Important Notes

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    TypeScript,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • Unit tests have been written where possible.

@radeusgd radeusgd added the CI: No changelog needed Do not require a changelog entry for this PR. label Jul 29, 2024
@radeusgd radeusgd self-assigned this Jul 29, 2024
Comment on lines 268 to 266
pkg.save()
pkg.save().get
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discarding the result of Try[...]... - not the best idea

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of using Try there, then? .get will crash with an exception on failure and not really report the failure either.

object CouldNotCreateDirectory extends Exception
case class CouldNotCreateDirectory(cause: Throwable) extends RuntimeException {
override def getMessage: String =
s"Could not create directory: ${cause.getMessage}. Perhaps there is a permission issue."
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

System.err.println(ex.getMessage());
ex.printStackTrace();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getMessage is sometimes unhelpful for Java exceptions, e.g. NoSuchFileException::getMessage returns just the path - but no comment - so from getMessage you have no idea what happened, what kind of exception this was - you just see a file path and wonder where did this come from...

The stack trace should be more helpful I think.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If so, the full stacktrace should be printed only when verbose mode is on. We don't want to show this to end users.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the alternative? As mentioned, getMessage is utterly useless. I guess I could try toString.

System.err.println(ex.getMessage());
ex.printStackTrace();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If so, the full stacktrace should be printed only when verbose mode is on. We don't want to show this to end users.

Comment on lines 268 to 266
pkg.save()
pkg.save().get
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of using Try there, then? .get will crash with an exception on failure and not really report the failure either.

@radeusgd radeusgd requested a review from hubertp July 30, 2024 11:27
@@ -1385,7 +1385,8 @@ private void launch(CommandLine line, Level logLevel, boolean logMasking) {
return BoxedUnit.UNIT;
});
} catch (IOException ex) {
System.err.println(ex.getMessage());
logger.error("Error during execution", ex);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could check if (Logger.isEnabledForLevel(Level.DEBUG)) { ...

@radeusgd radeusgd requested a review from hubertp August 5, 2024 09:13
@radeusgd radeusgd added the CI: Ready to merge This PR is eligible for automatic merge label Aug 5, 2024
@mergify mergify bot merged commit 4b35e0a into develop Aug 5, 2024
40 of 41 checks passed
@mergify mergify bot deleted the wip/radeusgd/propagate-dir-errors branch August 5, 2024 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants