| | 473 | /** |
|---|
| | 474 | * Add the given exceptionMessage and throwable as the startup error for this module. |
|---|
| | 475 | * This method loops over the stacktrace and adds the detailed message |
|---|
| | 476 | * |
|---|
| | 477 | * @param exceptionMessage optional. the default message to show on the first line of the error message |
|---|
| | 478 | * @param t throwable stacktrace to include in the error message |
|---|
| | 479 | */ |
|---|
| | 480 | public void setStartupErrorMessage(String exceptionMessage, Throwable t) { |
|---|
| | 481 | if (t == null) |
|---|
| | 482 | throw new ModuleException("Startup error value cannot be null", this.getModuleId()); |
|---|
| | 483 | |
|---|
| | 484 | StringBuffer sb = new StringBuffer(); |
|---|
| | 485 | |
|---|
| | 486 | // if exceptionMessage is not null, append it |
|---|
| | 487 | if (exceptionMessage != null) { |
|---|
| | 488 | sb.append(exceptionMessage); |
|---|
| | 489 | sb.append("\n"); |
|---|
| | 490 | } |
|---|
| | 491 | |
|---|
| | 492 | sb.append(t.getMessage()); |
|---|
| | 493 | sb.append("\n"); |
|---|
| | 494 | |
|---|
| | 495 | // loop over and append all stacktrace elements marking the "openmrs" ones |
|---|
| | 496 | for (StackTraceElement traceElement : t.getStackTrace()) { |
|---|
| | 497 | if (traceElement.getClassName().contains("openmrs")) |
|---|
| | 498 | sb.append(" ** "); |
|---|
| | 499 | sb.append(traceElement); |
|---|
| | 500 | sb.append("\n"); |
|---|
| | 501 | } |
|---|
| | 502 | |
|---|
| | 503 | this.startupErrorMessage = sb.toString(); |
|---|
| | 504 | } |
|---|
| | 505 | |
|---|