Skip to content

Commit

Permalink
Example with jax-rs error mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
tkountis committed Nov 2, 2023
1 parent 8b8d1c5 commit f63898e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright © 2023 Apple Inc. and the ServiceTalk project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.servicetalk.examples.http.jaxrs;

import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;

public class HelloWorldExceptionMapper implements ExceptionMapper<Throwable> {
@Override
public Response toResponse(final Throwable exception) {
exception.printStackTrace();
return Response.serverError().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public final class HelloWorldJaxRsApplication extends Application {
public Set<Class<?>> getClasses() {
return new HashSet<>(asList(
MultiPartFeature.class,
HelloWorldJaxRsResource.class
HelloWorldJaxRsResource.class,
HelloWorldExceptionMapper.class
)
);
}
Expand Down

0 comments on commit f63898e

Please sign in to comment.