Skip to content

Commit

Permalink
[Truffle] Fallback to SystemCallError when errno doesn't have a subclass
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Fish committed Jul 1, 2016
1 parent 67c88d5 commit f1d5875
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 0 additions & 6 deletions spec/truffle/tags/core/exception/system_call_error_tags.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
fails:SystemCallError.new accepts single Fixnum argument as errno
fails:SystemCallError.new constructs the appropriate Errno class
fails:SystemCallError.new returns an arity of -1 for the initialize method
fails:SystemCallError#errno returns nil when no errno given
fails:SystemCallError#errno returns the errno given as optional argument to new
fails:SystemCallError#message returns the default message when no message is given
fails:SystemCallError#message returns the message given as an argument to new
fails:SystemCallError.new requires at least one argument
fails:SystemCallError.new accepts an optional custom message preceding the errno
fails:SystemCallError.new accepts an optional third argument specifying the location
Original file line number Diff line number Diff line change
@@ -236,12 +236,18 @@ public DynamicObject errnoError(int errno, String message, Node currentNode) {
return systemCallError(String.format("Unknown Error (%s) - %s", errno, message), currentNode);
}

DynamicObject errnoClass = context.getCoreLibrary().getErrnoClass(errnoObj);
if(errnoClass == null){
errnoClass = context.getCoreLibrary().getSystemCallErrorClass();
message = "Unknown error: " + errno;
}

final DynamicObject errorMessage = StringOperations.createString(context, StringOperations.encodeRope(String.format("%s - %s", errnoObj.description(), message), UTF8Encoding.INSTANCE));

return ExceptionOperations.createRubyException(
context.getCoreLibrary().getErrnoClass(errnoObj),
errorMessage,
context.getCallStack().getBacktrace(currentNode));
errnoClass,
errorMessage,
context.getCallStack().getBacktrace(currentNode));
}

// IndexError

0 comments on commit f1d5875

Please sign in to comment.