Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor handling of InvalidRangeFormatException
This changeset adds InvalidRangeFormatExceptionMapper and removes the individual handling of InvalidRangeFormatExceptions throughout the code.
- Loading branch information
Jochen Schalanda
committed
Jan 13, 2015
1 parent
3860c6e
commit c84d610
Showing
18 changed files
with
107 additions
and
155 deletions.
There are no files selected for viewing
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
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
19 changes: 19 additions & 0 deletions
19
graylog2-server/src/main/java/org/graylog2/indexer/InvalidRangeFormatException.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,19 @@ | |||
package org.graylog2.indexer; | |||
|
|||
public class InvalidRangeFormatException extends RuntimeException { | |||
public InvalidRangeFormatException() { | |||
super("Invalid timerange parameters provided"); | |||
} | |||
|
|||
public InvalidRangeFormatException(String message) { | |||
super(message); | |||
} | |||
|
|||
public InvalidRangeFormatException(String message, Throwable cause) { | |||
super(message, cause); | |||
} | |||
|
|||
public InvalidRangeFormatException(Throwable cause) { | |||
super("Invalid timerange parameters provided", cause); | |||
} | |||
} |
20 changes: 20 additions & 0 deletions
20
graylog2-server/src/main/java/org/graylog2/indexer/InvalidRangeFormatExceptionMapper.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,20 @@ | |||
package org.graylog2.indexer; | |||
|
|||
import org.graylog2.plugin.rest.ApiError; | |||
|
|||
import javax.ws.rs.core.MediaType; | |||
import javax.ws.rs.core.Response; | |||
import javax.ws.rs.ext.ExceptionMapper; | |||
import javax.ws.rs.ext.Provider; | |||
|
|||
@Provider | |||
public class InvalidRangeFormatExceptionMapper implements ExceptionMapper<InvalidRangeFormatException> { | |||
@Override | |||
public Response toResponse(InvalidRangeFormatException exception) { | |||
return Response | |||
.status(Response.Status.BAD_REQUEST) | |||
.type(MediaType.APPLICATION_JSON_TYPE) | |||
.entity(new ApiError(exception.getMessage())) | |||
.build(); | |||
} | |||
} |
Oops, something went wrong.