Created
August 5, 2014 03:20
-
-
Save arielvalentin/c340ae45dd83af8fd9d9 to your computer and use it in GitHub Desktop.
Sample code Throwable vs RubyException
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The following block logs java.lang.Throwable correctly: http://www.slf4j.org/api/org/slf4j/Logger.html#error(java.lang.String,%20java.lang.Throwable) | |
begin | |
Java::ComGoogleCommonBase::Preconditions.check_argument(false, "I don't like you") | |
rescue => e | |
logger = Java::OrgSlf4j::LoggerFactory.get_logger('logger') | |
logger.error("This works", e) | |
end | |
# However RubyException is not a throwable and treats it as a java.lang.Object: http://www.slf4j.org/api/org/slf4j/Logger.html#error(java.lang.String,%20java.lang.Object...) | |
begin | |
raise "error" | |
rescue => e | |
logger = Java::OrgSlf4j::LoggerFactory.get_logger('logger') | |
logger.error("This doesn't", e) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment