ForbiddenException extends RuntimeException implements ErrorCode { @Override public String errorCode() { return errorCode; } ForbiddenException(String message);  ForbiddenException(String message, String errorCode);  ForbiddenException(String message, String errorCode, Throwable cause); @Override Severity severity(); @Override String errorCode();  }
@Test void errorCode() { var exception = new ForbiddenException("test", "CUSTOM_FORBIDDEN_ERROR_CODE", new Error()); assertThat(exception.errorCode()).isEqualTo("CUSTOM_FORBIDDEN_ERROR_CODE"); assertThat(exception.severity()).isEqualTo(Severity.WARN); assertThat(new ForbiddenException("test", "FORBIDDEN").errorCode()).isEqualTo("FORBIDDEN"); }