Download models/anomaly-detection/src/exception/exception.py from nivakaran/modelx: direct link, hf CLI and curl.
- Browser
- Download file 719 Bytes
-
https://huggingface.co/spaces/nivakaran/modelx/resolve/main/models/anomaly-detection/src/exception/exception.py
- Command line
-
hf download hf://spaces/nivakaran/modelx/models/anomaly-detection/src/exception/exception.py
-
curl -L -o exception.py https://huggingface.co/spaces/nivakaran/modelx/resolve/main/models/anomaly-detection/src/exception/exception.py
719 Bytes
| import sys | |
| class AnomalyDetectionException(Exception): | |
| """Custom exception for Anomaly Detection pipeline.""" | |
| def __init__(self, error_message, error_details: sys): | |
| self.error_message = error_message | |
| _, _, exc_tb = error_details.exc_info() | |
| self.lineno = exc_tb.tb_lineno | |
| self.file_name = exc_tb.tb_frame.f_code.co_filename | |
| def __str__(self): | |
| return "Error occurred in python script name [{0}] line number [{1}] error message [{2}]".format( | |
| self.file_name, self.lineno, str(self.error_message) | |
| ) | |
| if __name__ == '__main__': | |
| try: | |
| a = 1 / 0 | |
| except Exception as e: | |
| raise AnomalyDetectionException(e, sys) | |