Skip to content

Commit

Permalink
Update TestController.java
Browse files Browse the repository at this point in the history
  • Loading branch information
SentryMan committed Nov 26, 2024
1 parent 9a8f14a commit 7a504cf
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tests/test-jex/src/main/java/org/example/web/TestController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@
import java.io.IOException;
import java.util.Set;

import org.example.Person;

import io.avaje.http.api.BodyString;
import io.avaje.http.api.Controller;
import io.avaje.http.api.Default;
import io.avaje.http.api.ExceptionHandler;
import io.avaje.http.api.Filter;
import io.avaje.http.api.Get;
import io.avaje.http.api.InstrumentServerContext;
import io.avaje.http.api.Options;
import io.avaje.http.api.Path;
import io.avaje.http.api.Post;
import io.avaje.http.api.Produces;
import io.avaje.http.api.QueryParam;
import io.avaje.jex.Context;
import io.avaje.jex.FilterChain;
import io.helidon.webserver.http.ServerResponse;

@Path("test/")
@Controller
Expand Down Expand Up @@ -50,4 +54,21 @@ void filter(FilterChain chain) throws IOException {
System.err.println("do nothing lmao");
chain.proceed();
}

@ExceptionHandler
String exception(IllegalArgumentException ex) {
return "Err: " + ex;
}

@Produces(statusCode = 501)
@ExceptionHandler
HelloDto exceptionCtx(Exception ex, Context ctx) {
return null;
}

@ExceptionHandler(IllegalStateException.class)
void exceptionVoid(Context ctx) {
ctx.status(503);
ctx.text("IllegalStateException");
}
}

0 comments on commit 7a504cf

Please sign in to comment.