(ExceptionEvent event)
| 699 | |
| 700 | |
| 701 | public void exceptionEvent(ExceptionEvent event) { |
| 702 | ObjectReference or = event.exception(); |
| 703 | ReferenceType rt = or.referenceType(); |
| 704 | String exceptionName = rt.name(); |
| 705 | //Field messageField = Throwable.class.getField("detailMessage"); |
| 706 | Field messageField = rt.fieldByName("detailMessage"); |
| 707 | // System.out.println("field " + messageField); |
| 708 | Value messageValue = or.getValue(messageField); |
| 709 | // System.out.println("mess val " + messageValue); |
| 710 | |
| 711 | //"java.lang.ArrayIndexOutOfBoundsException" |
| 712 | int last = exceptionName.lastIndexOf('.'); |
| 713 | String message = exceptionName.substring(last + 1); |
| 714 | if (messageValue != null) { |
| 715 | String messageStr = messageValue.toString(); |
| 716 | if (messageStr.startsWith("\"")) { |
| 717 | messageStr = messageStr.substring(1, messageStr.length() - 1); |
| 718 | } |
| 719 | message += ": " + messageStr; |
| 720 | } |
| 721 | // System.out.println("mess type " + messageValue.type()); |
| 722 | //StringReference messageReference = (StringReference) messageValue.type(); |
| 723 | |
| 724 | // First just report the exception and its placement |
| 725 | reportException(message, or, event.thread()); |
| 726 | // Then try to pretty it up with a better message |
| 727 | handleCommonErrors(exceptionName, message, listener, sketchErr); |
| 728 | |
| 729 | if (editor != null) { |
| 730 | java.awt.EventQueue.invokeLater(() -> editor.onRunnerExiting(Runner.this)); |
| 731 | } |
| 732 | } |
| 733 | |
| 734 | |
| 735 | /** |
no test coverage detected