Spaces:
Sleeping
Sleeping
Download networksecurity/exception/exception.py from Divb30/network-intrusion-detection: direct link, hf CLI and curl.
- Browser
- Download file 766 Bytes
-
https://huggingface.co/spaces/Divb30/network-intrusion-detection/resolve/main/networksecurity/exception/exception.py
- Command line
-
hf download hf://spaces/Divb30/network-intrusion-detection/networksecurity/exception/exception.py
-
curl -L -o exception.py https://huggingface.co/spaces/Divb30/network-intrusion-detection/resolve/main/networksecurity/exception/exception.py
766 Bytes
| import sys | |
| from networksecurity.logging import logger | |
| class NetworkSecurityException(Exception): | |
| def __init__(self,error_message,error_details): | |
| 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 occured 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: | |
| logger.logging.info("Enter the try block") | |
| a=1/0 | |
| print("This will not be printed",a) | |
| except Exception as e: | |
| raise NetworkSecurityException(e,sys) |