private String name(ErrorCode c) { return prefix + ".error-" + c.getSeverity() + "-" + c.getErrorId(); }
public BaseException(final ErrorCode errorCode) { super( errorCode.toString()); this.errorCode = errorCode; }
@Test public void testSeverityErrorCount() { catcher.error(ErrorCode.medium(10, "hello world")); assertThat(registry.counter(this.config.getPrefix() + ".error-severity-MEDIUM-count") .getCount(), equalTo(1l)); }
@Subscribe public void error(ErrorCode c) { registry.meter(prefix + ".errors") .mark(); registry.counter(prefix + ".errors-count") .inc(); if (this.configuration.isErrorsByCode()) { registry.meter(name(c)) .mark(); registry.counter(name(c) + "-count") .inc(); } if (this.configuration.isErrorsByType()) { registry.meter(prefix + ".error-severity-" + c.getSeverity() .name()) .mark(); registry.counter(prefix + ".error-severity-" + c.getSeverity() .name() + "-count") .inc(); } }
public static ErrorCode medium(final int errorId, final String message) { return new ErrorCode( errorId, message, Severity.MEDIUM); }
@GET @Produces("text/plain") @Path("/fatal") public String fatal() { try { throw new InvalidStateException( Errors.SYSTEM_FAILURE.format("*eek*")); } catch (Exception e) { e.printStackTrace(); } return "unrecoverable fatal error"; }
@Test public void testSeverityErrorCount() { catcher.error(ErrorCode.medium(10, "hello world")); assertThat(registry.counter(this.config.getPrefix() + ".error-severity-MEDIUM-count") .getCount(), equalTo(0l)); }
public ErrorEvent(final BaseException exception) { code = exception.getErrorCode(); message = exception.getMessage(); fatal = Severity.FATAL.equals(code.getSeverity()); }
public static ErrorCode high(final int errorId, final String message) { return new ErrorCode( errorId, message, Severity.HIGH); }
@GET @Produces("text/plain") @Path("/error") public String error() { try { throw new InvalidStateException( Errors.QUERY_FAILURE.format("*eek*")); } catch (Exception e) { e.printStackTrace(); } return "error"; }
@Test public void testErrorCount() { catcher.error(ErrorCode.medium(10, "hello world")); assertThat(registry.counter(this.config.getPrefix() + ".error-MEDIUM-10-count") .getCount(), equalTo(1l)); }
public static ErrorCode low(final int errorId, final String message) { return new ErrorCode( errorId, message, Severity.LOW); }
@Test public void testEventErrorSuscriber() { new InvalidStateException( Errors.QUERY_FAILURE.format()); assertTrue(eventTriggered); }
public BaseException(final ErrorCode errorCode, final Throwable cause) { super( errorCode.toString(), cause); this.errorCode = errorCode; }
@Test public void testErrorCount() { catcher.error(ErrorCode.medium(10, "hello world")); assertThat(registry.counter(this.config.getPrefix() + ".error-MEDIUM-10-count") .getCount(), equalTo(0l)); }
public static ErrorCode critical(final int errorId, final String message) { return new ErrorCode( errorId, message, Severity.CRITICAL); }
@Test public void testErrorMeter() { catcher.error(ErrorCode.medium(10, "hello world")); assertThat(registry.meter(this.config.getPrefix() + ".error-MEDIUM-10") .getMeanRate(), greaterThan(0.00)); }
public static ErrorCode error(final int errorId, final String message, final Severity severity) { return new ErrorCode( errorId, message, severity); }
@Test public void testErrorSeverityMeter() { catcher.error(ErrorCode.medium(10, "hello world")); assertThat(registry.meter(this.config.getPrefix() + ".error-severity-MEDIUM") .getMeanRate(), equalTo(0.00)); }