Пример #1
0
  protected static void onMissingClass(Error err, EventInfo<?> e) {
    EventProxy.error = "Missing Event Handler Class!";
    EventProxy.errorDetails = new StringBuilder();

    EventProxy.addCrashDetailLine("\n");
    EventProxy.addCrashDetailLine(
        "You are seeing this message because an event callback was injected by the Event");
    EventProxy.addCrashDetailLine(
        "Injection Subsystem but the specified callback class was not defined! The");
    EventProxy.addCrashDetailLine("details of the missing callback are as follows:");
    EventProxy.addDetailLineBreak();
    EventProxy.addCrashDetailLine("      Event Name: " + e.getName());
    EventProxy.addCrashDetailLine("     Cancellable: " + e.isCancellable());
    EventProxy.addDetailLineBreak();
    EventProxy.addCrashDetailLine("  Callback class: " + err.getMessage().replace('/', '.'));
    EventProxy.addDetailLineBreak();
    EventProxy.addCrashDetailLine(
        "If you are the mod author then in order to fix the error you must provide an");
    EventProxy.addCrashDetailLine(
        "implementation for the specified class, or check that the class name and package");
    EventProxy.addCrashDetailLine("are correct.");
    EventProxy.addDetailLineBreak();
    EventProxy.addCrashDetailLine(
        "This is an unrecoverable error, please report it to the mod author and remove");
    EventProxy.addCrashDetailLine("the offending mod.");
    EventProxy.addStackTrace(err);

    throw new RuntimeErrorException(
        err,
        "Missing event handler class for event " + e.getName() + ", see crash report for details");
  }
Пример #2
0
  protected static void onMissingHandler(Error err, EventInfo<?> e) {
    String descriptor = err.getMessage();
    int dotPos = descriptor.lastIndexOf('.');
    int bracketPos = descriptor.indexOf('(');

    String signature = descriptor.substring(bracketPos);
    String sourceClass = e.getSource() != null ? e.getSource().getClass().getSimpleName() : "?";

    EventProxy.error = "Missing Event Handler Method!";
    EventProxy.errorDetails = new StringBuilder();

    EventProxy.addCrashDetailLine("\n");
    EventProxy.addCrashDetailLine(
        "You are seeing this message because an event callback was injected by the Event");
    EventProxy.addCrashDetailLine(
        "Injection Subsystem but the specified callback method was not defined. The");
    EventProxy.addCrashDetailLine("details of the missing callback are as follows:");
    EventProxy.addDetailLineBreak();
    EventProxy.addCrashDetailLine("      Event Name: " + e.getName());
    EventProxy.addCrashDetailLine("     Cancellable: " + e.isCancellable());
    EventProxy.addDetailLineBreak();
    EventProxy.addCrashDetailLine("  Callback class: " + descriptor.substring(0, dotPos));
    EventProxy.addCrashDetailLine(
        " Callback method: " + descriptor.substring(dotPos + 1, bracketPos));
    EventProxy.addDetailLineBreak();
    EventProxy.addCrashDetailLine(
        "If you are the mod author then in order to fix the error you must add a suitable");
    EventProxy.addCrashDetailLine(
        "callback method in the above class. The method signature should be as follows:");
    EventProxy.addDetailLineBreak();
    EventProxy.addCrashDetailLine(
        EventProxy.generateHandlerTemplate(
            descriptor.substring(dotPos + 1, bracketPos), signature, sourceClass));
    EventProxy.addDetailLineBreak();
    EventProxy.addCrashDetailLine(
        "This is an unrecoverable error, please report it to the mod author and remove");
    EventProxy.addCrashDetailLine("the offending mod.");
    EventProxy.addStackTrace(err);

    throw new RuntimeErrorException(
        err,
        "Missing event handler method for event " + e.getName() + ", see crash report for details");
  }