Catch Exception in a logger
This commit is contained in:
parent
0e65f6648b
commit
5be25735ae
2 changed files with 14 additions and 3 deletions
|
@ -29,14 +29,17 @@ public class Client<U extends User> extends Thread{
|
|||
writer.flush();
|
||||
writer.close();
|
||||
}catch(InvalidJwtException e){
|
||||
this.router.getExceptionLogger().setValue(e);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
this.router.getExceptionLogger().setValue(e);
|
||||
if(context != null && context.getResponseCode() == 0){
|
||||
try{
|
||||
context.response(500);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}catch(Exception ex){}
|
||||
}catch(Exception ex){
|
||||
this.router.getExceptionLogger().setValue(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(context != null) router.getLogger().setValue(context);
|
||||
|
@ -53,7 +56,9 @@ public class Client<U extends User> extends Thread{
|
|||
writer.response(401, this.router.getDefaultHeaders(type));
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}catch(Exception ex){}
|
||||
}catch(Exception ex){
|
||||
this.router.getExceptionLogger().setValue(ex);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ public class Router<U extends User>{
|
|||
}
|
||||
|
||||
private Locker<Context> logger;
|
||||
private Locker<Exception> exceptions;
|
||||
private RouteMapper<U>[] mappers;
|
||||
private List<RouteInterceptor> interceptors;
|
||||
private Response noFileFound;
|
||||
|
@ -42,6 +43,7 @@ public class Router<U extends User>{
|
|||
|
||||
public Router() throws Exception{
|
||||
this.logger = new Locker<>();
|
||||
this.exceptions = new Locker<>();
|
||||
int types = RequestType.values().length;
|
||||
this.mappers = new RouteMapper[types];
|
||||
this.interceptors = new ArrayList<>();
|
||||
|
@ -142,6 +144,10 @@ public class Router<U extends User>{
|
|||
return this.logger;
|
||||
}
|
||||
|
||||
public Locker<Exception> getExceptionLogger(){
|
||||
return this.exceptions;
|
||||
}
|
||||
|
||||
public void listen(int port, boolean ssl) throws Exception{
|
||||
if (ssl) { // Not needed with the use of a proxy
|
||||
try {
|
||||
|
|
Loading…
Add table
Reference in a new issue