FtcXtensible/src/main/java/org/ftccommunity/ftcxtensible/robot/ExtensibleOpMode.java
private void handleException(@org.jetbrains.annotations.Nullable LinkedList<Object> list, Exception e) {
        Log.e(TAG,
                "An exception occurred running the OpMode \"" + getCallerClassName(e) + "\"", e);
        if (e instanceof NullPointerException && (e.getMessage() == null || e.getMessage().equals(""))) {
            String className = "";
            String lineNumber = "";
            if (e.getStackTrace().length > 0 && e.getStackTrace()[0] != null) {
                className = e.getStackTrace()[0].getClassName();
                lineNumber = Integer.toString(e.getStackTrace()[0].getLineNumber());
            }

            e = new NullPointerException("Something went awry in the OpMode, because something" +
                    " seems to be null." +
                    (lineNumber.equals("") && className.equals("") ?
                            "" : " Check the line " + lineNumber + "@" + className + " for possible errors."));
        }

        status().setCurrentStateType(RobotStatus.Type.IDK);
        RobotStatus.Type failure = status().getCurrentStateType();
        if (onFailure(this, failure, RobotStatus.MainStates.EXCEPTION, e) >= 0) {
            status().setCurrentStateType(RobotStatus.Type.SUCCESS);
            if (list != null) {
                for (Object o : list) {
                    onFailure(this, failure, RobotStatus.MainStates.EXCEPTION, o);
                }
            }
        } else {
            if (this.getClass().isAnnotationPresent(RobotsDontQuit.class)) {
                // // TODO: 9/5/2016
            }

            throw (RuntimeException) (e instanceof RuntimeException ? e : new RuntimeException(e));
//                final Exception ex = e;
//                Thread codeRestarter = new Thread(new Runnable() {
//                    @Override
//                    public void run() {
//                        skipNextLoop = Integer.MAX_VALUE;
//                        //final Gamepad gamepad1 = ExtensibleOpMode.super.gamepad1;
//                        //final Gamepad gamepad2 = ExtensibleOpMode.super.gamepad2;
//                        RobotLog.setGlobalErrorMsg(ex.toString() + "\n Robot Code will restart automatically in 5 seconds");
//                        final OpModeManager mgr = opModeManager();
//
//                        final String currentName = mgr.getActiveOpModeName();
//                        mgr.stopActiveOpMode();
//                        try {
//                            for (int i = 5; i >= 0; i--) {
//                                RobotLog.clearGlobalErrorMsg();
//                                RobotLog.setGlobalErrorMsg(ex.toString() + "\n Robot Code will restart automatically in " + i + " seconds");
//                                Thread.sleep(1000);
//                            }
//                        } catch (InterruptedException e1) {
//                            e1.printStackTrace();
//                        }
//                        RobotLog.clearGlobalErrorMsg();
//                        try {
//                            Thread.sleep(20);
//                        } catch (InterruptedException e1) {
//                            e1.printStackTrace();
//                        }
//                        try {
//                            do {
//                                Log.i(TAG, "Attempted to start " + currentName);
//                                RobotLog.setGlobalErrorMsg("Attempting to start " + currentName);
//                                Thread.sleep(20);
//                                RobotLog.clearGlobalErrorMsg();
//                                Thread.sleep(20);
//                                mgr.initActiveOpMode(currentName);
//                                mgr.startActiveOpMode();
//                                mgr.runActiveOpMode(new Gamepad[]{gamepad1, gamepad2});
//                            } while (!mgr.getActiveOpModeName().equals(currentName));
//                        } catch (InterruptedException e1) {
//                            e1.printStackTrace();
//                        }
//                    }
//                });
//                codeRestarter.setName(opModeManager().getActiveOpModeName() + " Restarter");
//                codeRestarter.start();
//            } else {
//                status().setCurrentStateType(RobotStatus.Type.FAILURE);
//                RobotLog.setGlobalErrorMsg(e.toString());
//                Throwables.propagate(e);
//            }
        }
    }
/**
     * Handles an user code exception
     *
     * @param list the list of objects to process
     * @param e    the exception thrown by user code
     */
Handles an user code exception
@param list the list of objects to process
@param e    the exception thrown by user code
Handles an user code exception @param list the list of objects to process @param e the exception thrown by user code
private void handleException(@org.jetbrains.annotations.Nullable LinkedList<Object> list, Exception e) {
        Log.e(TAG,
                "An exception occurred running the OpMode \"" + getCallerClassName(e) + "\"", e);
        if (e instanceof NullPointerException && (e.getMessage() == null || e.getMessage().equals(""))) {
            String className = "";
            String lineNumber = "";
            if (e.getStackTrace().length > 0 && e.getStackTrace()[0] != null) {
                className = e.getStackTrace()[0].getClassName();
                lineNumber = Integer.toString(e.getStackTrace()[0].getLineNumber());
            }
            e = new NullPointerException("Something went awry in the OpMode, because something" +
                    " seems to be null." +
                    (lineNumber.equals("") && className.equals("") ?
                            "" : " Check the line " + lineNumber + "@" + className + " for possible errors."));
        }
        status().setCurrentStateType(RobotStatus.Type.IDK);
        RobotStatus.Type failure = status().getCurrentStateType();
        if (onFailure(this, failure, RobotStatus.MainStates.EXCEPTION, e) >= 0) {
            status().setCurrentStateType(RobotStatus.Type.SUCCESS);
            if (list != null) {
                for (Object o : list) {
                    onFailure(this, failure, RobotStatus.MainStates.EXCEPTION, o);
                }
            }
        } else {
            if (this.getClass().isAnnotationPresent(RobotsDontQuit.class)) {
            }
            throw (RuntimeException) (e instanceof RuntimeException ? e : new RuntimeException(e));
                        final String currentName = mgr.getActiveOpModeName();
                        mgr.stopActiveOpMode();
                        try {
                            for (int i = 5; i >= 0; i--) {
                                RobotLog.clearGlobalErrorMsg();
                                RobotLog.setGlobalErrorMsg(ex.toString() + "\n Robot Code will restart automatically in " + i + " seconds");
                                Thread.sleep(1000);
                            }
                        } catch (InterruptedException e1) {
                            e1.printStackTrace();
                        }
                        RobotLog.clearGlobalErrorMsg();
                        try {
                            Thread.sleep(20);
                        } catch (InterruptedException e1) {
                            e1.printStackTrace();
                        }
                        try {
                            do {
                                Log.i(TAG, "Attempted to start " + currentName);
                                RobotLog.setGlobalErrorMsg("Attempting to start " + currentName);
                                Thread.sleep(20);
                                RobotLog.clearGlobalErrorMsg();
                                Thread.sleep(20);
                                mgr.initActiveOpMode(currentName);
                                mgr.startActiveOpMode();
                                mgr.runActiveOpMode(new Gamepad[]{gamepad1, gamepad2});
                            } while (!mgr.getActiveOpModeName().equals(currentName));
                        } catch (InterruptedException e1) {
                            e1.printStackTrace();
                        }
                    }
                });
                codeRestarter.setName(opModeManager().getActiveOpModeName() + " Restarter");
                codeRestarter.start();
            } else {
                status().setCurrentStateType(RobotStatus.Type.FAILURE);
                RobotLog.setGlobalErrorMsg(e.toString());
                Throwables.propagate(e);
            }
        }
    }
private void handleException ( @ org . jetbrains . annotations . Nullable LinkedList < Object > list , Exception e ) { Log . e ( TAG , "An exception occurred running the OpMode \"" + getCallerClassName ( e ) + "\"" , e ) ; if ( e instanceof NullPointerException && ( e . getMessage ( ) == null || e . getMessage ( ) . equals ( "" ) ) ) { String className = "" ; String lineNumber = "" ; if ( e . getStackTrace ( ) . length > 0 && e . getStackTrace ( ) [ 0 ] != null ) { className = e . getStackTrace ( ) [ 0 ] . getClassName ( ) ; lineNumber = Integer . toString ( e . getStackTrace ( ) [ 0 ] . getLineNumber ( ) ) ; } e = new NullPointerException ( "Something went awry in the OpMode, because something" + " seems to be null." + ( lineNumber . equals ( "" ) && className . equals ( "" ) ? "" : " Check the line " + lineNumber + "@" + className + " for possible errors." ) ) ; } status ( ) . setCurrentStateType ( RobotStatus . Type . IDK ) ; RobotStatus . Type failure = status ( ) . getCurrentStateType ( ) ; if ( onFailure ( this , failure , RobotStatus . MainStates . EXCEPTION , e ) >= 0 ) { status ( ) . setCurrentStateType ( RobotStatus . Type . SUCCESS ) ; if ( list != null ) { for ( Object o : list ) { onFailure ( this , failure , RobotStatus . MainStates . EXCEPTION , o ) ; } } } else { if ( this . getClass ( ) . isAnnotationPresent ( RobotsDontQuit . class ) ) { } throw ( RuntimeException ) ( e instanceof RuntimeException ? e : new RuntimeException ( e ) ) ; } }
Handles an user code exception
 @param list the list of objects to process
 @param e    the exception thrown by user code
Handles an user code exception @param list the list of objects to process @param e the exception thrown by user code
// // TODO: 9/5/2016 //                final Exception ex = e; //                Thread codeRestarter = new Thread(new Runnable() { //                    @Override //                    public void run() { //                        skipNextLoop = Integer.MAX_VALUE; //                        //final Gamepad gamepad1 = ExtensibleOpMode.super.gamepad1; //                        //final Gamepad gamepad2 = ExtensibleOpMode.super.gamepad2; //                        RobotLog.setGlobalErrorMsg(ex.toString() + "\n Robot Code will restart automatically in 5 seconds"); //                        final OpModeManager mgr = opModeManager(); // //                        final String currentName = mgr.getActiveOpModeName(); //                        mgr.stopActiveOpMode(); //                        try { //                            for (int i = 5; i >= 0; i--) { //                                RobotLog.clearGlobalErrorMsg(); //                                RobotLog.setGlobalErrorMsg(ex.toString() + "\n Robot Code will restart automatically in " + i + " seconds"); //                                Thread.sleep(1000); //                            } //                        } catch (InterruptedException e1) { //                            e1.printStackTrace(); //                        } //                        RobotLog.clearGlobalErrorMsg(); //                        try { //                            Thread.sleep(20); //                        } catch (InterruptedException e1) { //                            e1.printStackTrace(); //                        } //                        try { //                            do { //                                Log.i(TAG, "Attempted to start " + currentName); //                                RobotLog.setGlobalErrorMsg("Attempting to start " + currentName); //                                Thread.sleep(20); //                                RobotLog.clearGlobalErrorMsg(); //                                Thread.sleep(20); //                                mgr.initActiveOpMode(currentName); //                                mgr.startActiveOpMode(); //                                mgr.runActiveOpMode(new Gamepad[]{gamepad1, gamepad2}); //                            } while (!mgr.getActiveOpModeName().equals(currentName)); //                        } catch (InterruptedException e1) { //                            e1.printStackTrace(); //                        } //                    } //                }); //                codeRestarter.setName(opModeManager().getActiveOpModeName() + " Restarter"); //                codeRestarter.start(); //            } else { //                status().setCurrentStateType(RobotStatus.Type.FAILURE); //                RobotLog.setGlobalErrorMsg(e.toString()); //                Throwables.propagate(e); //            }