-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(catalogues): added in more support for open data catalogues [202…
…4-11-27]
- Loading branch information
1 parent
610dae1
commit 13bf83b
Showing
5 changed files
with
153 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,36 @@ | ||
from typing import Optional | ||
|
||
class CatSessionError(Exception): | ||
pass | ||
|
||
class CatExplorerError(Exception): | ||
pass | ||
|
||
class OpenDataSoftExplorerError(Exception): | ||
""" | ||
Custom exception class for OpenDataSoft Explorer errors with colored output using ANSI codes. | ||
""" | ||
# ANSI escape codes for colors | ||
RED = '\033[91m' | ||
YELLOW = '\033[93m' | ||
RESET = '\033[0m' | ||
|
||
def __init__(self, message: str, original_error: Optional[Exception] = None) -> None: | ||
self.message = message | ||
self.original_error = original_error | ||
|
||
# Build the error message with color | ||
error_msg = ( | ||
f"{self.RED}OpenDataSoftExplorer Error: {message}{self.RESET}" | ||
) | ||
|
||
if original_error: | ||
error_msg += ( | ||
f"\n{self.YELLOW}Original error: " | ||
f"{str(original_error)}{self.RESET}" | ||
) | ||
|
||
super().__init__(error_msg) | ||
|
||
def __str__(self) -> str: | ||
return self.args[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters