Skip to content

Commit 260cae0

Browse files
committed
[Truffle] Translate load errors for JRuby when file can't be loaded via '-r' switch.
1 parent 6f90864 commit 260cae0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

truffle/src/main/java/org/jruby/truffle/TruffleBridgeImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,13 @@ public void init() {
155155
truffleContext.getFeatureManager().require(requiredLibrary, null);
156156
} catch (IOException e) {
157157
throw new RuntimeException(e);
158+
} catch (RaiseException e) {
159+
// Translate LoadErrors for JRuby since we're outside an ExceptionTranslatingNode.
160+
if (e.getRubyException().getLogicalClass() == truffleContext.getCoreLibrary().getLoadErrorClass()) {
161+
throw truffleContext.getRuntime().newLoadError(e.getRubyException().getMessage().toString(), requiredLibrary);
162+
} else {
163+
throw e;
164+
}
158165
}
159166
}
160167

0 commit comments

Comments
 (0)