exception example 10

This commit is contained in:
Mert Gör ☭ 2023-08-22 11:22:01 +03:00
parent dbabadffb4
commit d17c628da0
No known key found for this signature in database
GPG Key ID: 2100A876D55B39B9
1 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,18 @@
def bar(a):
print('bar başladı')
if a < 0:
raise ValueError('Argüman negatif olamaz')
print('bar bitti')
def foo(a):
print('foo başladı')
try:
bar(a)
except Exception as e:
print(f"Exception foo'da ele alındı ve yeniden fırlatılıyor: {e}")
raise
print('foo bitti')
try:
foo(-10)
except Exception as e:
print(f'Exception dışarıda ele alındı: {e}')