Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating error status codes for exceptions #178

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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