Skip to content

Commit

Permalink
Updating error status codes for exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsibilla committed Oct 19, 2023
1 parent 4be9542 commit 579fab8
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/routes/entity_CRUD/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from pathlib import Path

from flask import Blueprint, jsonify, request, Response, current_app, abort, json
import logging
import requests
Expand Down Expand Up @@ -105,11 +103,11 @@ def multiple_components():
for dataset in json_data_dict.get('datasets'):
if 'dataset_link_abs_dir' in dataset:
if not os.path.exists(dataset['dataset_link_abs_dir']):
return Response(f"The filepath specified with 'dataset_link_abs_dir' does not exist: {dataset['dataset_link_abs_dir']}", 500)
return Response(f"The filepath specified with 'dataset_link_abs_dir' does not exist: {dataset['dataset_link_abs_dir']}", 400)
if not os.path.isdir(dataset['dataset_link_abs_dir']):
return Response(f"The filepath specified with 'dataset_link_abs_dir is not a directory: {dataset['dataset_link_abs_dir']}", 500)
return Response(f"The filepath specified with 'dataset_link_abs_dir is not a directory: {dataset['dataset_link_abs_dir']}", 400)
else:
return Response("Required field 'dataset_link_abs_dir' is missing from dataset", 500)
return Response("Required field 'dataset_link_abs_dir' is missing from dataset", 400)

requested_group_uuid = None
if 'group_uuid' in component_request:
Expand All @@ -133,7 +131,7 @@ def multiple_components():
f"Creating a directory as: {new_directory_path} with a symbolic link to: {dataset['dataset_link_abs_dir']}")
os.symlink(dataset['dataset_link_abs_dir'], new_directory_path)
else:
return Response("Required field 'dataset_link_abs_dir' is missing from dataset", 500)
return Response("Required field 'dataset_link_abs_dir' is missing from dataset", 400)

return jsonify(new_datasets_list)
except HTTPException as hte:
Expand Down

0 comments on commit 579fab8

Please sign in to comment.