Skip to content

Commit

Permalink
Update database error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
padix-key committed Oct 24, 2022
1 parent 3fbab8f commit 5b0c3b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/biotite/database/entrez/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"Service unavailable",
"Server Error",
"ID list is empty",
"Supplied id parameter is empty",
"Resource temporarily unavailable",
"Failed to retrieve sequence",
"Failed to understand id",
Expand All @@ -40,7 +41,10 @@ def check_for_errors(message):
If the message contains an error message.
"""
# Error always appear at the end of message
message_end = message[-100:]
message_end = message[-200:]
# Seemingly arbitrary '+' characters are in NCBI error messages
message_end = message_end.replace("+", "")
for error_msg in _error_messages:
if error_msg in message_end:
# Often whitespace is also replaced by '+' in error message
if error_msg.replace(" ", "") in message_end:
raise RequestError(error_msg)
3 changes: 2 additions & 1 deletion src/biotite/database/rcsb/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def _assert_valid_file(response_text, pdb_id):
if any(err_msg in response_text for err_msg in [
"404 Not Found",
"<title>RCSB Protein Data Bank Error Page</title>",
"No fasta files were found."
"No fasta files were found.",
"No valid PDB IDs were submitted.",
]):
raise RequestError("PDB ID {:} is invalid".format(pdb_id))

0 comments on commit 5b0c3b4

Please sign in to comment.