Skip to content

Commit

Permalink
add parsing exception handling (#266)
Browse files Browse the repository at this point in the history
Co-authored-by: Al Niessner <Al.Niessner@xxx.xxx>
  • Loading branch information
al-niessner and Al Niessner authored Mar 1, 2023
1 parent 6f26cef commit 4cf874f
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import javax.validation.constraints.Min;
import org.antlr.v4.runtime.misc.ParseCancellationException;
import org.antlr.v4.runtime.NoViableAltException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -114,6 +116,10 @@ protected ResponseEntity<Object> processs(EndpointHandler handler, URIParameters
} catch (NothingFoundException e) {
log.warn("Could not find any matching reference(s) in database.");
return new ResponseEntity<Object>(ErrorFactory.build(e, this.request), HttpStatus.NOT_FOUND);
} catch (NoViableAltException | ParseCancellationException e) {
log.warn("The given search string '" + parameters.getQuery() + "' cannot be parsed.");
return new ResponseEntity<Object>(ErrorFactory.build(new ParseCancellationException("The given search string '"
+ parameters.getQuery() + "' cannot be parsed."), this.request), HttpStatus.BAD_REQUEST);
} catch (UnknownGroupNameException e) {
log.error("Group name not implemented", e);
return new ResponseEntity<Object>(ErrorFactory.build(e, this.request),
Expand Down

0 comments on commit 4cf874f

Please sign in to comment.