1- class PUBMLSTError (Exception ):
2- """Base exception for PUBMLST utilities."""
1+ class PubMLSTError (Exception ):
2+ """Base exception for PubMLST utilities."""
3+
34 def __init__ (self , message = None ):
4- super (PUBMLSTError , self ).__init__ (f"PUBMLST: { message } " )
5+ super (PubMLSTError , self ).__init__ (f"PubMLST: { message } " )
6+
57
8+ class CredentialsFileNotFound (PubMLSTError ):
9+ """Raised when the PubMLST credentials file is not found."""
610
7- class CredentialsFileNotFound (PUBMLSTError ):
8- """Raised when the PUBMLST credentials file is not found."""
911 def __init__ (self , credentials_file ):
1012 message = (
1113 f"Credentials file not found: { credentials_file } . "
@@ -14,8 +16,9 @@ def __init__(self, credentials_file):
1416 super (CredentialsFileNotFound , self ).__init__ (message )
1517
1618
17- class InvalidCredentials (PUBMLSTError ):
19+ class InvalidCredentials (PubMLSTError ):
1820 """Raised when the credentials file contains invalid or missing fields."""
21+
1922 def __init__ (self , missing_fields ):
2023 message = (
2124 "Invalid credentials: All fields (CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN, ACCESS_SECRET) "
@@ -25,8 +28,9 @@ def __init__(self, missing_fields):
2528 super (InvalidCredentials , self ).__init__ (message )
2629
2730
28- class PathResolutionError (PUBMLSTError ):
31+ class PathResolutionError (PubMLSTError ):
2932 """Raised when the file path cannot be resolved from the configuration."""
33+
3034 def __init__ (self , config_key ):
3135 message = (
3236 f"Failed to resolve the path for configuration key: '{ config_key } '. "
@@ -35,31 +39,38 @@ def __init__(self, config_key):
3539 super (PathResolutionError , self ).__init__ (message )
3640
3741
38- class SaveSessionError (PUBMLSTError ):
42+ class SaveSessionError (PubMLSTError ):
3943 """Raised when saving the session token fails."""
44+
4045 def __init__ (self , db , reason ):
4146 message = f"Failed to save session token for database '{ db } ': { reason } "
4247 super (SaveSessionError , self ).__init__ (message )
4348
4449
45- class SessionTokenRequestError (PUBMLSTError ):
50+ class SessionTokenRequestError (PubMLSTError ):
4651 """Raised when requesting a session token fails."""
52+
4753 def __init__ (self , db , status_code , response_text ):
48- message = f"Failed to fetch session token for database '{ db } ': { status_code } - { response_text } "
54+ message = (
55+ f"Failed to fetch session token for database '{ db } ': { status_code } - { response_text } "
56+ )
4957 super (SessionTokenRequestError , self ).__init__ (message )
5058
5159
52- class SessionTokenResponseError (PUBMLSTError ):
60+ class SessionTokenResponseError (PubMLSTError ):
5361 """Raised when the session token response is invalid."""
62+
5463 def __init__ (self , db , reason ):
5564 message = f"Invalid session token response for database '{ db } ': { reason } "
5665 super (SessionTokenResponseError , self ).__init__ (message )
5766
58- class InvalidURLError (PUBMLSTError ):
67+
68+ class InvalidURLError (PubMLSTError ):
5969 """Raised when the provided URL does not match any known patterns."""
70+
6071 def __init__ (self , href ):
6172 message = (
62- f"The provided URL '{ href } ' does not match any known PUBMLST API patterns. "
73+ f"The provided URL '{ href } ' does not match any known PubMLST API patterns. "
6374 "Please check the URL for correctness."
6475 )
6576 super (InvalidURLError , self ).__init__ (message )
0 commit comments