public <T extends FileNotFoundException> ErrorExplanation<T> createExplanation(T throwable) { return new ErrorExplanation<>(throwable, "File not found: " + throwable.getMessage()); } });
public <T extends FileNotFoundException> ErrorExplanation<T> createExplanation(T throwable) { return new ErrorExplanation<T>(throwable, "File not found: " + throwable.getMessage()); } });
public <T extends FileNotFoundException> ErrorExplanation<T> createExplanation(T throwable) { return new ErrorExplanation<T>(throwable, "File not found: " + throwable.getMessage()); } });
public ErrorExplainer() { addExplanationFactory(FileNotFoundException.class, new ErrorExplanationFactory<FileNotFoundException>(){ public <T extends FileNotFoundException> ErrorExplanation<T> createExplanation(T throwable) { return new ErrorExplanation<T>(throwable, "File not found: " + throwable.getMessage()); } }); addExplanationFactory(SAXParseException.class, new ErrorExplanationFactory<SAXParseException>(){ public <T extends SAXParseException> ErrorExplanation<T> createExplanation(T throwable) { final String message = "XML error at line " + throwable.getLineNumber() + ", column " + throwable.getColumnNumber() + "\n" + throwable.getMessage(); if (throwable.getLineNumber() <= 0 || throwable.getColumnNumber() <= 0){ System.out.println("throwable = " + throwable); } return new ParseErrorExplanation<T>(throwable, message, throwable.getLineNumber()-1, // as they are indexed from 1 throwable.getColumnNumber()-1); } }); }
public ErrorExplainer() { addExplanationFactory(FileNotFoundException.class, new ErrorExplanationFactory<FileNotFoundException>(){ public <T extends FileNotFoundException> ErrorExplanation<T> createExplanation(T throwable) { return new ErrorExplanation<T>(throwable, "File not found: " + throwable.getMessage()); } }); addExplanationFactory(SAXParseException.class, new ErrorExplanationFactory<SAXParseException>(){ public <T extends SAXParseException> ErrorExplanation<T> createExplanation(T throwable) { final String message = "XML error at line " + throwable.getLineNumber() + ", column " + throwable.getColumnNumber() + "\n" + throwable.getMessage(); if (throwable.getLineNumber() <= 0 || throwable.getColumnNumber() <= 0){ System.out.println("throwable = " + throwable); } return new ParseErrorExplanation<T>(throwable, message, throwable.getLineNumber()-1, // as they are indexed from 1 throwable.getColumnNumber()-1); } }); }
public ErrorExplainer() { addExplanationFactory(FileNotFoundException.class, new ErrorExplanationFactory<FileNotFoundException>(){ public <T extends FileNotFoundException> ErrorExplanation<T> createExplanation(T throwable) { return new ErrorExplanation<>(throwable, "File not found: " + throwable.getMessage()); } }); addExplanationFactory(SAXParseException.class, new ErrorExplanationFactory<SAXParseException>(){ public <T extends SAXParseException> ErrorExplanation<T> createExplanation(T throwable) { final String message = "XML error at line " + throwable.getLineNumber() + ", column " + throwable.getColumnNumber() + "\n" + throwable.getMessage(); if (throwable.getLineNumber() <= 0 || throwable.getColumnNumber() <= 0){ System.out.println("throwable = " + throwable); } return new ParseErrorExplanation<>(throwable, message, throwable.getLineNumber()-1, // as they are indexed from 1 throwable.getColumnNumber()-1); } }); }
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<>(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 }