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

Fixes crash when an asset isn't available. #9

Merged
merged 5 commits into from
Jan 27, 2013

Conversation

mikaa123
Copy link
Contributor

As mentioned in #7, catapult was crashing whenever it didn't find an asset.

This pull request intercepts the exception and issues a warning.

say "Write asset: #{filename}"
asset.write_to(filename)
end
rescue
Copy link
Contributor

Choose a reason for hiding this comment

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

This will rescue any exception, not just Asset not found related ones. So if the block fails for any other reason the output will be misleading.

If the idea is to not crash the process when it fails then it should output more details about what went wrong so it's easier to fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, it was misleading.

If the idea is to not crash the process when it fails then it should output more details about what went wrong so > it's easier to fix it.

That's the idea. Now I simply print the exception message whenever something is thrown, and add it to a list of warnings to be shown at the end.

What do you think of this approach?

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems good - just one thing:

If I'm not mistaken you shouldn't rescue Exception and use StandardError instead - otherwise stuff like hitting ctrl+c or running kill $PID won't quit the program.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah, that would have been nasty. Thanks for pointing it out.

@@ -27,12 +27,25 @@ def build(*assets)

say "Building: #{Catapult.root}"

warnings = Array.new
Copy link
Owner

Choose a reason for hiding this comment

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

Cool stuff! Can you use [] ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Surely. :)

maccman added a commit that referenced this pull request Jan 27, 2013
Fixes crash when an asset isn't available.
@maccman maccman merged commit 538ac4a into maccman:master Jan 27, 2013
@mraaroncruz
Copy link

@maccman Could you push this to rubygems please. Thank you!

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.

4 participants