Download src/exception.py from rishitpant/system-threat-forecaster: direct link, hf CLI and curl.
- Browser
- Download file 759 Bytes
-
https://huggingface.co/spaces/rishitpant/system-threat-forecaster/resolve/main/src/exception.py
- Command line
-
hf download hf://spaces/rishitpant/system-threat-forecaster/src/exception.py
-
curl -L -o exception.py https://huggingface.co/spaces/rishitpant/system-threat-forecaster/resolve/main/src/exception.py
759 Bytes
| import sys | |
| import logging | |
| from src.logger import logging | |
| def error_message_details(error, error_detail: sys): | |
| _, _, exc_tb = error_detail.exc_info() | |
| file_name = exc_tb.tb_frame.f_code.co_filename | |
| error_message = ( | |
| "Error occurred in script name [{0}] " | |
| "line number [{1}] " | |
| "error message [{2}]" | |
| ).format( | |
| file_name, | |
| exc_tb.tb_lineno, | |
| str(error) | |
| ) | |
| return error_message | |
| class CustomException(Exception): | |
| def __init__(self, error_message, error_details: sys): | |
| self.error_message = error_message_details( | |
| error_message, | |
| error_details | |
| ) | |
| super().__init__(self.error_message) | |
| def __str__(self): | |
| return self.error_message | |