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 authored and Stefan Negrea committed Aug 13, 2015
1 parent 411a812 commit 62c5c5c
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 62c5c5c

Please sign in to comment.