1
1
/*
2
- * Copyright 2002-2013 the original author or authors.
2
+ * Copyright 2002-2014 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
25
25
26
26
import org .jruby .Ruby ;
27
27
import org .jruby .RubyArray ;
28
- import org .jruby .RubyException ;
29
28
import org .jruby .RubyNil ;
30
29
import org .jruby .ast .ClassNode ;
31
30
import org .jruby .ast .Colon2Node ;
@@ -116,10 +115,12 @@ private static String findClassName(Node rootNode) {
116
115
117
116
/**
118
117
* Find the first {@link ClassNode} under the supplied {@link Node}.
119
- * @return the found {@code ClassNode}, or {@code null}
120
- * if no {@link ClassNode} is found
118
+ * @return the corresponding {@code ClassNode}, or {@code null} if none found
121
119
*/
122
120
private static ClassNode findClassNode (Node node ) {
121
+ if (node == null ) {
122
+ return null ;
123
+ }
123
124
if (node instanceof ClassNode ) {
124
125
return (ClassNode ) node ;
125
126
}
@@ -229,9 +230,6 @@ private Object convertFromRubyArray(IRubyObject[] rubyArray, Class<?> returnType
229
230
/**
230
231
* Exception thrown in response to a JRuby {@link RaiseException}
231
232
* being thrown from a JRuby method invocation.
232
- * <p>Introduced because the {@code RaiseException} class does not
233
- * have useful {@link Object#toString()}, {@link Throwable#getMessage()},
234
- * and {@link Throwable#printStackTrace} implementations.
235
233
*/
236
234
@ SuppressWarnings ("serial" )
237
235
public static class JRubyExecutionException extends NestedRuntimeException {
@@ -242,12 +240,7 @@ public static class JRubyExecutionException extends NestedRuntimeException {
242
240
* @param ex the cause (must not be {@code null})
243
241
*/
244
242
public JRubyExecutionException (RaiseException ex ) {
245
- super (buildMessage (ex ), ex );
246
- }
247
-
248
- private static String buildMessage (RaiseException ex ) {
249
- RubyException rubyEx = ex .getException ();
250
- return (rubyEx != null && rubyEx .message != null ) ? rubyEx .message .toString () : "Unexpected JRuby error" ;
243
+ super (ex .getMessage (), ex );
251
244
}
252
245
}
253
246
0 commit comments