public static void throwException(CodeBuilder b, Class type, String message) {
        TypeDesc desc = TypeDesc.forClass(type);
        b.newObject(desc);
        b.dup();
        if (message == null) {
            b.invokeConstructor(desc, null);
        } else {
            b.loadConstant(message);
            b.invokeConstructor(desc, new TypeDesc[] {TypeDesc.STRING});
        }
        b.throwObject();
    }
public static void throwException ( CodeBuilder b , Class type , String message ) { TypeDesc desc = TypeDesc . forClass ( type ) ; b . newObject ( desc ) ; b . dup ( ) ; if ( message == null ) { b . invokeConstructor ( desc , null ) ; } else { b . loadConstant ( message ) ; b . invokeConstructor ( desc , new TypeDesc [ ] { TypeDesc . STRING } ) ; } b . throwObject ( ) ; }
Generate code to throw an exception with an optional message.
@param b {@link CodeBuilder} to which to add code
@param type type of the object to throw
@param message optional message to provide to the constructor