public <T extends Throwable> ErrorExplanation<? extends Throwable> getErrorExplanation(T throwable, boolean traverseCauses){ Throwable cause = throwable; // Works through an error and its causes trying to find an explainer to match do { // This factory is not going to be even vaguely related to the type of the original exception // if we have moved on to its causes // The explanation only cares about the cause - it forgets the original exception // so we can return an explanation for any throwable cause ErrorExplanationFactory fac = getFactory(cause); if (fac != null){ return fac.createExplanation(cause); } cause = cause.getCause(); }while (traverseCauses && cause != null); return new ErrorExplanation<>(throwable, throwable.getMessage()); // return the error itself }
public <T extends Throwable> ErrorExplanation<? extends Throwable> getErrorExplanation(T throwable, boolean traverseCauses){ Throwable cause = throwable; // Works through an error and its causes trying to find an explainer to match do { // This factory is not going to be even vaguely related to the type of the original exception // if we have moved on to its causes // The explanation only cares about the cause - it forgets the original exception // so we can return an explanation for any throwable cause ErrorExplanationFactory fac = getFactory(cause); if (fac != null){ return fac.createExplanation(cause); } cause = cause.getCause(); }while (traverseCauses && cause != null); return new ErrorExplanation<T>(throwable, throwable.getMessage()); // return the error itself }
public <T extends Throwable> ErrorExplanation<? extends Throwable> getErrorExplanation(T throwable, boolean traverseCauses){ Throwable cause = throwable; // Works through an error and its causes trying to find an explainer to match do { // This factory is not going to be even vaguely related to the type of the original exception // if we have moved on to its causes // The explanation only cares about the cause - it forgets the original exception // so we can return an explanation for any throwable cause ErrorExplanationFactory fac = getFactory(cause); if (fac != null){ return fac.createExplanation(cause); } cause = cause.getCause(); }while (traverseCauses && cause != null); return new ErrorExplanation<T>(throwable, throwable.getMessage()); // return the error itself }