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
200
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
64
Pythons in the tower of babel
mariocj89
0
90
Other Decks in Programming
See All in Programming
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
920
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
350
subpath importsで始めるモック生活
10tera
0
300
Arm移行タイムアタック
qnighy
0
320
受け取る人から提供する人になるということ
little_rubyist
0
230
Flutterを言い訳にしない!アプリの使い心地改善テクニック5選🔥
kno3a87
1
180
Remix on Hono on Cloudflare Workers
yusukebe
1
290
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
330
C++でシェーダを書く
fadis
6
4.1k
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Building Your Own Lightsaber
phodgson
103
6.1k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
92
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
720
Designing for Performance
lara
604
68k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Speed Design
sergeychernyshev
25
620
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!