Skip to content

Commit

Permalink
Showing 3 changed files with 12 additions and 25 deletions.
1 change: 0 additions & 1 deletion spec/truffle/tags/core/exception/errno_tags.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
fails:Errno::EAGAIN is the same class as Errno::EWOULDBLOCK if they represent the same errno value
fails:Errno::EINVAL.new can be called with no arguments
Original file line number Diff line number Diff line change
@@ -113,26 +113,6 @@ public DynamicObject captureBacktrace(DynamicObject exception, int offset) {

}

@CoreMethod(names = "message")
public abstract static class MessageNode extends CoreMethodArrayArgumentsNode {

@Specialization
public Object message(
DynamicObject exception,
@Cached("createBinaryProfile()") ConditionProfile messageProfile) {
final Object message = Layouts.EXCEPTION.getMessage(exception);

if (messageProfile.profile(message == nil())) {
final String className = Layouts.MODULE.getFields(
Layouts.BASIC_OBJECT.getLogicalClass(exception)).getName();
return createString(StringOperations.encodeRope(className, UTF8Encoding.INSTANCE));
} else {
return message;
}
}

}

@Primitive(name = "exception_message")
public abstract static class MessagePrimitiveNode extends CoreMethodArrayArgumentsNode {

@@ -170,10 +150,14 @@ public DynamicObject exceptionErrnoError(
int errno,
DynamicObject location) {
final String errorMessage;
if (RubyGuards.isRubyString(location)) {
errorMessage = " @ " + location.toString() + " - " + message.toString();
if (message != nil()) {
if (RubyGuards.isRubyString(location)) {
errorMessage = " @ " + location.toString() + " - " + message.toString();
} else {
errorMessage = " - " + message.toString();
}
} else {
errorMessage = " - " + message.toString();
errorMessage = "";
}
return coreExceptions().errnoError(errno, errorMessage, this);
}
6 changes: 5 additions & 1 deletion truffle/src/main/ruby/core/exception.rb
Original file line number Diff line number Diff line change
@@ -40,8 +40,12 @@ def ==(other)
backtrace == other.backtrace
end

def message
self.to_s
end

def to_s
msg = message
msg = Truffle.invoke_primitive :exception_message, self
if msg.nil?
self.class.to_s
else

0 comments on commit d2319de

Please sign in to comment.