API - return 404 instead of 500 when map file not found - fix #192

This commit is contained in:
Sam
2022-06-22 11:04:34 +02:00
parent 3b47353a7b
commit 9c2ba31b96
3 changed files with 24 additions and 19 deletions

View File

@ -13,7 +13,7 @@ from flask import (
send_from_directory,
)
from sqlalchemy import exc
from werkzeug.exceptions import RequestEntityTooLarge
from werkzeug.exceptions import NotFound, RequestEntityTooLarge
from werkzeug.utils import secure_filename
from fittrackee import appLog, db
@ -798,6 +798,8 @@ def get_map(map_id: int) -> Union[HttpResponse, Response]:
current_app.config['UPLOAD_FOLDER'],
workout.map,
)
except NotFound:
return NotFoundErrorResponse('Map file does not exist.')
except Exception as e:
return handle_error_and_return_response(e)