Currently, the users with dss cannot handle exceptions.
So, I suggest adding the exception handler.
public class Application{
public static void main() throws InterruptedException {
DssRestServer dssRestServer = new DssRestServer("127.0.0.1", 8181);
dssRestServer
.addDssService(new MyService())
.addExceptionHandler(new GlobalExceptionHandler());
dssRestServer.start();
}
}
public class GlobalExceptionHandler implements DssServiceExceptionHandler {
// to handle all NullpointerException
@ExceptionHandler(exception = NullPointerException.class)
public DssRestServiceResponse nullPointerExceptionHandler(DssRestServiceRequest request) {
System.out.println("Global nullPointerExceptionHandler");
return new Response("To handle nullPointerException");
}
// to handle IOException only on myservice
@ServiceExceptionHandler(service = MyService.class, exception = IOException.class)
public void serviceExceptionHandler() {
System.out.println("IOException in my service");
}
}
Currently, the users with dss cannot handle exceptions.
So, I suggest adding the exception handler.
like this.