Skip to content

Commit

Permalink
Catch PatternSyntaxException and return badRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
tsegismont committed Aug 12, 2015
1 parent aced033 commit abb30db
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.regex.PatternSyntaxException;

import javax.inject.Inject;
import javax.ws.rs.Consumes;
Expand Down Expand Up @@ -105,11 +106,13 @@ public Response findMetrics(

try {
return metricObservable
.map(MetricDefinition::new)
.toList()
.map(ApiUtils::collectionToResponse)
.toBlocking()
.lastOrDefault(null);
.map(MetricDefinition::new)
.toList()
.map(ApiUtils::collectionToResponse)
.toBlocking()
.lastOrDefault(null);
} catch (PatternSyntaxException e) {
return ApiUtils.badRequest(e);
} catch (Exception e) {
return ApiUtils.serverError(e);
}
Expand Down

0 comments on commit abb30db

Please sign in to comment.