Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Exceptional Exceptions - EuroPython 2019
Search
Mario Corchero
July 11, 2019
Programming
1
110
Exceptional Exceptions - EuroPython 2019
Mario Corchero
July 11, 2019
Tweet
Share
More Decks by Mario Corchero
See All by Mario Corchero
Linux & Python
mariocj89
0
72
Exceptional Exceptions
mariocj89
2
100
unittest.Mock in detail
mariocj89
0
210
Mocks: Successfully isolating the snake
mariocj89
1
84
Effortless logging: A deep dive into Python logging module
mariocj89
0
730
PyLondinium18 - London python Meetup
mariocj89
0
58
It's time for datetime
mariocj89
0
65
Pythons in the tower of babel
mariocj89
0
90
Other Decks in Programming
See All in Programming
Jakarta EE meets AI
ivargrimstad
0
240
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
220
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
120
macOS でできる リアルタイム動画像処理
biacco42
9
2.4k
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
Contemporary Test Cases
maaretp
0
140
Realtime API 入門
riofujimon
0
150
Micro Frontends Unmasked Opportunities, Challenges, Alternatives
manfredsteyer
PRO
0
110
TypeScript Graph でコードレビューの心理的障壁を乗り越える
ysk8hori
2
1.2k
Figma Dev Modeで変わる!Flutterの開発体験
watanave
0
150
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
130
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
Featured
See All Featured
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Into the Great Unknown - MozCon
thekraken
32
1.5k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
430
What's in a price? How to price your products and services
michaelherold
243
12k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Building Adaptive Systems
keathley
38
2.3k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Six Lessons from altMBA
skipperchong
27
3.5k
Bash Introduction
62gerente
608
210k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
We Have a Design System, Now What?
morganepeng
50
7.2k
Transcript
© 2019 Bloomberg Finance L.P. All rights reserved. Exceptional Exceptions:
How to properly raise, handle and create them EuroPython 2019 July 11, 2019 Mario Corchero @mariocj89
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Let’s just raise an exception, right?
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Let’s just raise an exception, right?
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Let’s go step by step
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. How to capture an exception
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. What can go in the except?
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. What can go in the except?
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Using finally
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Using else
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Order of execution?
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. What about returning in the middle?
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Logging exceptions Use exc_info to include exception information
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Logging exceptions
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Logging exceptions Errors should never pass silently. Unless explicitly silenced.
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Logging exceptions
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Logging exceptions But... When I have...
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Logging exceptions But... What if I know...
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Logging exceptions
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Logging exceptions
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Logging exceptions
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Logging exceptions
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Scoping of the except See PEP 3110. In short: exception -> traceback -> stack frame -> exception
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Raise it!
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. The tricky, raise within except
© 2018 Bloomberg Finance L.P. All rights reserved. The tricky,
raise within except
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Reraise
© 2018 Bloomberg Finance L.P. All rights reserved. Reraise
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Reraise
© 2018 Bloomberg Finance L.P. All rights reserved. Reraise
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Chaining exceptions
© 2018 Bloomberg Finance L.P. All rights reserved. Chaining exceptions
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Eliding previous exception
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Eliding previous exception
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. False friends: NotImplemented Passes without printing. 37,762 hits in GitHub as of July 2019.
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Raise on a thread?
© 2018 Bloomberg Finance L.P. All rights reserved. Raise on
a thread?
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. The exception hierarchy Check https://docs.python.org/3/library/exceptions.html
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Exception attributes
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Exception attributes
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Exception attributes
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Creating new classes
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Creating new classes
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Exception hierarchy
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Multiple inheritance • Decimal: • Requests:
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Can I use Error codes?
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Conclusions
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Extra content!
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. New magic in 3.8
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. New magic in 3.8
© 2019 Bloomberg Finance L.P. All rights reserved. Cycles when
reraising
© 2019 Bloomberg Finance L.P. All rights reserved. Cycles when
reraising
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Returns in finally
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Returns in finally
© 2018 Bloomberg Finance L.P. All rights reserved. © 2019
Bloomberg Finance L.P. All rights reserved. Returns in finally
© 2019 Bloomberg Finance L.P. All rights reserved. Thank you!
Questions?? Also, ask me about travelling to Extremadura!