function exitflag = RAPTOR_errorhandler(exitflag)
% Handle errors returned by RAPTOR_predictive_step
        switch exitflag
            case 1
                warning('exceeded maximum newton iterations')
            case 2
                warning('Divergence in newton iterations')
            case 3
                warning('NaNs found')
            case 4
                warning('inf in dftilde_dxk1');
            case 5
                warning('Negative temperature')             
            case 6
                warning('Negative current')
            case 7
                warning('Negative density')
            case 8
                warning('exceeded maximum newton iterations to solve problem with x')
            case 9
                warning('user chose to exit during debugging')
            otherwise
                return
        end
end