Skip to content

Commit

Permalink
correct some mistakes with new Error API
Browse files Browse the repository at this point in the history
  • Loading branch information
enebo committed Jun 20, 2024
1 parent 1284bf6 commit a51b85d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/RubyClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,8 @@ protected RubyClass(Ruby runtime, RubyClass superClazz, CallSite[] extraCallSite
* Corresponds to rb_class_new in MRI.
*/
public static RubyClass newClass(Ruby runtime, RubyClass superClass) {
if (superClass == runtime.getClassClass()) typeError(runtime.getCurrentContext(), "can't make subclass of Class");
if (superClass.isSingleton()) typeError(runtime.getCurrentContext(), "can't make subclass of virtual class");
if (superClass == runtime.getClassClass()) throw typeError(runtime.getCurrentContext(), "can't make subclass of Class");
if (superClass.isSingleton()) throw typeError(runtime.getCurrentContext(), "can't make subclass of virtual class");
return new RubyClass(runtime, superClass);
}

Expand Down
12 changes: 6 additions & 6 deletions core/src/main/java/org/jruby/api/Error.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

public class Error {
/**
* Throw a TypeError with the given message.
* Create a TypeError with the given message.
*
* @param context the current thread context
* @param object which is the wrong type
Expand All @@ -24,7 +24,7 @@ public static TypeError typeError(ThreadContext context, IRubyObject object, Str
}

/**
* Throw a TypeError with the given message.
* Create a TypeError with the given message.
*
* @param context the current thread context
* @param startOfMessage the start of the message
Expand All @@ -36,26 +36,26 @@ public static TypeError typeError(ThreadContext context, String startOfMessage,
}

/**
* Throw a TypeError with the given message.
* Create a TypeError with the given message.
*
* @param context the current thread context
* @param object which is the wrong type
* @param expectedType the expected type that object should have been
*/
public static TypeError typeError(ThreadContext context, IRubyObject object, RubyModule expectedType) {
throw createTypeError(context, createTypeErrorMessage(context, object, expectedType));
return createTypeError(context, createTypeErrorMessage(context, object, expectedType));
}

/**
* Throw a TypeError with the given message.
* Create a TypeError with the given message.
*
* @param context the current thread context
* @param message to be the message of the exception. Note that this message should
* be properly formatted using RubyStringBuilder.str() or you
* absolutely know it is clean ASCII-7BIT
*/
public static TypeError typeError(ThreadContext context, String message) {
throw createTypeError(context, message);
return createTypeError(context, message);
}

/**
Expand Down

0 comments on commit a51b85d

Please sign in to comment.