Skip to content

Commit 7934521

Browse files
author
Roland Schuller
committed
From Exception to Throwable
1 parent 048efb0 commit 7934521

File tree

3 files changed

+22
-28
lines changed

3 files changed

+22
-28
lines changed

src/main/java/at/itopen/simplerest/RestHttpRequestDispatchHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public static void process(Conversion conversion, ChannelHandlerContext ctx) thr
137137
conversion.getServer().getRootEndpoint().getNOT_FOUND().CallEndpoint(conversion, null);
138138
}
139139
}
140-
} catch (Exception e) {
140+
} catch (Throwable e) {
141141
conversion.setException(e);
142142
}
143143

src/main/java/at/itopen/simplerest/conversion/Conversion.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class Conversion {
2222
private Request request;
2323
private final Response response;
2424
private final ChannelHandlerContext ctx;
25-
private Exception exception;
25+
private Throwable exception;
2626
private long startTime;
2727
private RestHttpServer server;
2828
private Map<String, Object> data = new HashMap<>();
@@ -81,15 +81,15 @@ public Response getResponse() {
8181
*
8282
* @param exception
8383
*/
84-
public void setException(Exception exception) {
84+
public void setException(Throwable exception) {
8585
this.exception = exception;
8686
}
8787

8888
/**
8989
*
9090
* @return
9191
*/
92-
public Exception getException() {
92+
public Throwable getException() {
9393
return exception;
9494
}
9595

src/main/java/at/itopen/simplerest/endpoints/ErrorEndpoint.java

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,25 @@
1111
import java.util.List;
1212
import java.util.Map;
1313

14-
1514
/**
1615
*
1716
* @author roland
1817
*/
1918
public class ErrorEndpoint extends RestEndpoint {
2019

21-
2220
private class ErrorData {
21+
2322
String message;
24-
List<String> lines=new ArrayList<>();
23+
List<String> lines = new ArrayList<>();
2524

2625
public ErrorData(String message) {
27-
if (message==null)
28-
message="Null Pointer!";
26+
if (message == null) {
27+
message = "Null Pointer!";
28+
}
2929
this.message = message;
3030
}
31-
32-
public void addLine(String line)
33-
{
31+
32+
public void addLine(String line) {
3433
lines.add(line);
3534
}
3635

@@ -41,38 +40,33 @@ public String getMessage() {
4140
public List<String> getLines() {
4241
return lines;
4342
}
44-
45-
46-
47-
48-
43+
4944
}
50-
45+
5146
private ErrorData data;
52-
47+
5348
/**
5449
*
5550
*/
5651
public ErrorEndpoint() {
5752
super("ERROR");
58-
53+
5954
}
60-
55+
6156
/**
6257
*
6358
* @param conversion
6459
* @param UrlParameter
6560
*/
6661
@Override
67-
public void Call(Conversion conversion, Map<String,String> UrlParameter) {
68-
Exception exception=conversion.getException();
69-
data=new ErrorData(exception.getMessage());
70-
for (StackTraceElement stackTraceElement:exception.getStackTrace())
71-
{
62+
public void Call(Conversion conversion, Map<String, String> UrlParameter) {
63+
Throwable exception = conversion.getException();
64+
data = new ErrorData(exception.getMessage());
65+
for (StackTraceElement stackTraceElement : exception.getStackTrace()) {
7266
data.addLine(stackTraceElement.toString());
7367
}
7468
conversion.getResponse().setData(data);
75-
69+
7670
}
77-
71+
7872
}

0 commit comments

Comments
 (0)