Skip to content

Commit 7ba455c

Browse files
authored
Create custom-exception-type.md
1 parent 8743f53 commit 7ba455c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: Create Custom Exception Type
3+
description: Create a Custom Exception Type that can be called with raise.
4+
author: mrcool7387
5+
tags: python,error-creation,organisation,utility
6+
---
7+
8+
```py
9+
class ExceptionName(Exception):
10+
def __init__(message: str):
11+
super().__init__(message)
12+
13+
# Usage
14+
a: int = 1
15+
16+
if a > 0: #Simple if function
17+
raise ExceptionName('Error Message') #Rasing the Custom Exception
18+
```

0 commit comments

Comments
 (0)