From d17c628da0a82bc259ba42a4a014a9bcc67cbb34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20G=C3=B6r?= Date: Tue, 22 Aug 2023 11:22:01 +0300 Subject: [PATCH] exception example 10 --- python-temel/exception.example.10.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 python-temel/exception.example.10.py diff --git a/python-temel/exception.example.10.py b/python-temel/exception.example.10.py new file mode 100644 index 0000000..707408a --- /dev/null +++ b/python-temel/exception.example.10.py @@ -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}')