@Test public void testPrettyPrintNullSafe2() { ModelFactory mf = ModelFactory.eINSTANCE; ErrorReport report = mf.createErrorReport(); report.setStatus(mf.createStatus()); Reports.prettyPrint(report); }
@Test public void testClearEventMessage() { ErrorReport event = createTestReport(); Reports.clearMessages(event); assertThat(event.getStatus().getMessage(), is(ANONYMIZED_TAG)); }
@Test public void testPrettyPrintSkipsNullException() { ModelFactory mf = ModelFactory.eINSTANCE; ErrorReport report = mf.createErrorReport(); report.setStatus(mf.createStatus()); String prettyPrint = Reports.prettyPrint(report); assertThat(prettyPrint, not(containsString("Exception"))); }
@Test public void testPrettyPrintNullSafe3() { ModelFactory mf = ModelFactory.eINSTANCE; ErrorReport report = mf.createErrorReport(); report.setStatus(mf.createStatus()); Throwable t = mf.createThrowable(); t.setClassName("org.test"); report.getStatus().setException(t); Reports.prettyPrint(report); }
@Test public void testCreateAnonymizedSendCopyInsertNameAndEmail() { ModelFactory mf = ModelFactory.eINSTANCE; ErrorReport report = mf.createErrorReport(); settings.setName("foobarbaz"); settings.setEmail("*****@*****.**"); ErrorReport copy = Reports.createAnonymizedSendCopy(report, settings, configuration); assertThat(copy.getName(), is("foobarbaz")); assertThat(copy.getEmail(), is("*****@*****.**")); }
public static void appFail(Throwable ex, String message) { // TODO: allow app to handle fail message report here. For example // integrate google app reports // Log.d(DEFAULT_LOG_TAG, message); // System.exit(-1); if (ex == null) { ex = new NativeScriptException(message); } // TODO: We need to know whether to fail the app fast here - e.g. System.exit or just raise an // exception try { UncheckedThrow.Throw(ex); } catch (NativeScriptException e) { if (e == ex) { // exception is not caught by user code, go to the JavaScript side to raise the // __uncaughtError handler // TODO: We may want to allow JS code to mark the exception as Handled // don't throw exception to v8 if v8 is not initialized yet if (!initialized) { passUncaughtExceptionToJsNative(e, ErrorReport.getErrorMessage(e)); } } // re-throw the exception to crash the current thread UncheckedThrow.Throw(e); } }
private int process(String filename) throws ParserConfigurationException, SAXException, IOException { logger.info("Starting validating on: {}", filename); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); // validation and namespaces ON dbf.setNamespaceAware(true); dbf.setValidating(true); dbf.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA); DocumentBuilder db = dbf.newDocumentBuilder(); errorReport = new ErrorReport(); db.setErrorHandler(errorReport); Document doc = db.parse(new File(filename)); if (errorReport.isValid()) { logger.info("***** File {} is VALID XML! :-D *****", filename); } else { logger.error("**** File {} is INVALID XML :`( *****", filename); logger.info("Error report:\n" + errorReport.toString()); } return errorReport.exitStatus(); }
@Test public void testCreateAnonymizedSendCopyAnonymizes() { ModelFactory mf = ModelFactory.eINSTANCE; ErrorReport report = mf.createErrorReport(); report.setStatus(mf.createStatus()); java.lang.Throwable throwable = new RuntimeException("test exception"); throwable.fillInStackTrace(); Throwable t = Reports.newThrowable(throwable); report.getStatus().setException(t); settings.setAnonymizeMessages(true); settings.setAnonymizeStrackTraceElements(true); configuration.setAcceptedPackages(new ArrayList<String>()); ErrorReport copy = Reports.createAnonymizedSendCopy(report, settings, configuration); assertThat(copy.getStatus().getMessage(), is(Constants.HIDDEN)); StackTraceElement stackTraceElement = copy.getStatus().getException().getStackTrace().get(0); assertThat(stackTraceElement.getClassName(), is(Constants.HIDDEN)); assertThat(stackTraceElement.getMethodName(), is(Constants.HIDDEN)); assertThat(stackTraceElement.getFileName(), is(Constants.HIDDEN)); assertThat(stackTraceElement.getLineNumber(), is(-1)); }