Skip to content

Commit

Permalink
Merge pull request #97 from metno/issue92
Browse files Browse the repository at this point in the history
add exception handling
  • Loading branch information
TAlonglong authored Jan 3, 2025
2 parents 5a9671c + 246586e commit a779150
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mapgen/modules/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,13 @@ def handle_request(map_object, full_request):
result = mapscript.msIO_getStdoutBufferBytes()
mapscript.msIO_resetHandlers()
else:
mapscript.msIO_installStdoutToBuffer()
dispatch_status = map_object.OWSDispatch(ows_req)
try:
mapscript.msIO_installStdoutToBuffer()
dispatch_status = map_object.OWSDispatch(ows_req)
except Exception as e:
logger.error(f"status_code=500, mapscript fails to parse query parameters: {str(full_request)}, with error: {str(e)}")
raise HTTPError(response_code='500 Internal Server Error',
response=f"mapscript fails to parse query parameters: {str(full_request)}, with error: {str(e)}")
if dispatch_status != mapscript.MS_SUCCESS:
logger.debug(f"DISPATCH status {dispatch_status}")
content_type = mapscript.msIO_stripStdoutBufferContentType()
Expand Down

0 comments on commit a779150

Please sign in to comment.