|
1 |
| package com.agical.rmock.core.exception; |
|
2 |
| |
|
3 |
| import java.io.PrintWriter; |
|
4 |
| import java.io.StringWriter; |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| public abstract class RMockSystemException extends RuntimeException { |
|
12 |
| private static final long serialVersionUID = 1L; |
|
13 |
| |
|
14 |
43
| public RMockSystemException(String s) {
|
|
15 |
43
| super(s);
|
|
16 |
| } |
|
17 |
| |
|
18 |
2
| public RMockSystemException(String msg, Throwable cause) {
|
|
19 |
2
| super(getMessageAndCause(msg, cause));
|
|
20 |
| } |
|
21 |
| |
|
22 |
0
| public RMockSystemException(Throwable cause) {
|
|
23 |
0
| super(getMessageAndCause(null , cause));
|
|
24 |
| } |
|
25 |
| |
|
26 |
22
| public RMockSystemException() {
|
|
27 |
| } |
|
28 |
| |
|
29 |
2
| private static String getMessageAndCause(String msg, Throwable cause) {
|
|
30 |
2
| StringWriter writer = new StringWriter();
|
|
31 |
2
| PrintWriter printWriter = new PrintWriter(writer);
|
|
32 |
2
| if (msg != null) {
|
|
33 |
2
| printWriter.println(msg);
|
|
34 |
| } |
|
35 |
2
| printWriter.println("caused by:");
|
|
36 |
2
| printWriter.println(cause);
|
|
37 |
2
| cause.printStackTrace(printWriter);
|
|
38 |
2
| return writer.toString();
|
|
39 |
| } |
|
40 |
| } |