File tree Expand file tree Collapse file tree 1 file changed +0
-13
lines changed Expand file tree Collapse file tree 1 file changed +0
-13
lines changed Original file line number Diff line number Diff line change 114
114
"contributors" : [],
115
115
"code" : " class ExceptionName(BaseException):\n def __init__(message: str):\n super().__init__(message)\n\n # Usage\n a: int = 1\n\n if a > 0:\n raise ExceptionName('Error Message')\n "
116
116
},
117
- {
118
- "title" : " Handle File Not Found Error" ,
119
- "description" : " Attempts to open a file and handles the case where the file does not exist." ,
120
- "author" : " axorax" ,
121
- "tags" : [
122
- " python" ,
123
- " error-handling" ,
124
- " file" ,
125
- " utility"
126
- ],
127
- "contributors" : [],
128
- "code" : " def read_file_safe(filepath):\n try:\n with open(filepath, 'r') as file:\n return file.read()\n except FileNotFoundError:\n return \" File not found!\"\n\n # Usage:\n print(read_file_safe('nonexistent.txt')) # Output: 'File not found!'\n "
129
- },
130
117
{
131
118
"title" : " Retry Function Execution on Exception" ,
132
119
"description" : " Retries a function execution a specified number of times if it raises an exception." ,
You can’t perform that action at this time.
0 commit comments