-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: exceptions are refactored not to use JAX-RS exceptions in servic…
…es (#18)
- Loading branch information
Showing
8 changed files
with
62 additions
and
34 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
app/src/main/java/ch/sbb/polarion/extension/generic/exception/ObjectNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package ch.sbb.polarion.extension.generic.exception; | ||
|
||
public class ObjectNotFoundException extends RuntimeException { | ||
public ObjectNotFoundException(String message) { | ||
super(message); | ||
} | ||
|
||
public ObjectNotFoundException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
.../java/ch/sbb/polarion/extension/generic/rest/exception/ObjectNotFoundExceptionMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package ch.sbb.polarion.extension.generic.rest.exception; | ||
|
||
import ch.sbb.polarion.extension.generic.exception.ObjectNotFoundException; | ||
import com.polarion.core.util.logging.Logger; | ||
|
||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.ext.ExceptionMapper; | ||
import javax.ws.rs.ext.Provider; | ||
|
||
@Provider | ||
public class ObjectNotFoundExceptionMapper implements ExceptionMapper<ObjectNotFoundException> { | ||
private static final Logger logger = Logger.getLogger(ObjectNotFoundExceptionMapper.class); | ||
|
||
public Response toResponse(ObjectNotFoundException e) { | ||
logger.error("Not found error in controller: " + e.getMessage(), e); | ||
return Response.status(Response.Status.NOT_FOUND.getStatusCode()) | ||
.entity(e.getMessage()) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters