Skip to content

Commit

Permalink
Catch error instead of 500 (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulineribeyre authored Jun 9, 2022
1 parent b57410d commit 0258577
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 9 deletions.
5 changes: 4 additions & 1 deletion sheepdog/blueprint/routes/views/program/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ def create_project(program):
doc.pop("state", None)
doc.pop("released", None)

node.props.update(doc)
try:
node.props.update(doc)
except AttributeError as e:
raise UserError(f"ERROR: {e}")

res_doc = dict(
{"type": "project", "programs": {"id": program_node.node_id}}, **doc
Expand Down
2 changes: 1 addition & 1 deletion sheepdog/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def get_suggestion(value, choices):
message = " Did you mean '{}'?".format(suggestion)
else:
message = ""
except: # pylint: disable=bare-except
except Exception:
pass
return message

Expand Down
2 changes: 1 addition & 1 deletion sheepdog/utils/transforms/bcr_xml_to_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def xpath(
result = root.xpath(path, namespaces=self.namespaces)
except etree.XPathEvalError:
result = []
except:
except Exception:
raise
rlen = len(result)
if rlen < 1 and expected:
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/datadict/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def use_ssl(request):
try:
# one of [False, True, None]
return request.param
except:
except Exception:
return None


Expand All @@ -165,7 +165,7 @@ def isolation_level(request):
try:
# one of ["READ_COMMITTED", "REPEATABLE_READ", "SERIALIZABLE", None]
return request.param
except:
except Exception:
return None


Expand Down
2 changes: 1 addition & 1 deletion tests/integration/datadict/submission/test_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ def just_raise_exception(self):
try:
r = put_example_entities_together(client, submitter)
assert len(r.json["transactional_errors"]) == 1, r.data
except:
except Exception:
raise


Expand Down
4 changes: 2 additions & 2 deletions tests/integration/datadictwithobjid/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def use_ssl(request):
try:
# one of [False, True, None]
return request.param
except:
except Exception:
return None


Expand All @@ -163,7 +163,7 @@ def isolation_level(request):
try:
# one of ["READ_COMMITTED", "REPEATABLE_READ", "SERIALIZABLE", None]
return request.param
except:
except Exception:
return None


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def just_raise_exception(self):
try:
r = put_example_entities_together(client, submitter)
assert len(r.json["transactional_errors"]) == 1, r.data
except:
except Exception:
raise


Expand Down

0 comments on commit 0258577

Please sign in to comment.