Catch Errors on routes
This commit is contained in:
parent
b1575e5b52
commit
25a384cc63
4 changed files with 10 additions and 9 deletions
|
@ -30,7 +30,7 @@ public class Client<U extends User> extends Thread{
|
|||
writer.close();
|
||||
}catch(InvalidJwtException e){
|
||||
this.router.getExceptionLogger().setValue(e);
|
||||
}catch(Exception e){
|
||||
}catch(Throwable e){
|
||||
this.router.getExceptionLogger().setValue(e);
|
||||
if(context != null && context.getResponseCode() == 0){
|
||||
try{
|
||||
|
|
|
@ -43,7 +43,7 @@ public class DependencyInjector{
|
|||
|
||||
Object applyDependency(Constructor<?> constructor, Parameter parameter, Map<Class<?>, Object> cache){
|
||||
Injection annotation = parameter.getAnnotation(Injection.class);
|
||||
if(annotation != null) return this.map.get(annotation.name());
|
||||
if(annotation != null) return this.map.get(annotation.value());
|
||||
for(BiFunction<Constructor<?>, Parameter, Object> function : builders){
|
||||
Object result = function.apply(constructor, parameter);
|
||||
if(result != null) return result;
|
||||
|
@ -63,4 +63,4 @@ public class DependencyInjector{
|
|||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,6 +2,6 @@ package dev.peerat.framework;
|
|||
|
||||
public @interface Injection{
|
||||
|
||||
String name();
|
||||
String value();
|
||||
|
||||
}
|
||||
|
|
|
@ -4,20 +4,17 @@ import java.io.BufferedReader;
|
|||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.security.Key;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.net.ssl.SSLServerSocket;
|
||||
|
@ -37,8 +34,12 @@ import org.jose4j.lang.JoseException;
|
|||
|
||||
public class Router<U extends User>{
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
private Locker<Context> logger;
|
||||
private Locker<Exception> exceptions;
|
||||
private Locker<Throwable> exceptions;
|
||||
private RouteMapper<U>[] mappers;
|
||||
private List<RouteInterceptor> interceptors;
|
||||
private Response noFileFound;
|
||||
|
@ -226,7 +227,7 @@ public class Router<U extends User>{
|
|||
return this.logger;
|
||||
}
|
||||
|
||||
public Locker<Exception> getExceptionLogger(){
|
||||
public Locker<Throwable> getExceptionLogger(){
|
||||
return this.exceptions;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue