Here's A Smarter Way To Use Exception Objects // Python Tips

preview_player
Показать описание


🎓 Courses:

👍 If you enjoyed this content, give this video a like. If you want to watch more of my upcoming videos, consider subscribing to my channel!

👀 Code reviewers:
- Yoriz
- Ryan Laursen
- Sybren A. Stüvel
- Dale Hagglund

#arjancodes #softwaredesign #python

DISCLAIMER - The links in this description might be affiliate links. If you purchase a product or service through one of those links, I may receive a small commission. There is no additional charge to you. Thanks for supporting my channel so I can continue to provide you with free content each week!
Рекомендации по теме
Комментарии
Автор

You can also add a `__str__` method to your custom Exception so that you can dynamically build an error string from the provided data rather than having to pass it.

You could also pass a string to the custom Exception and use it in your `__str__` so you can add some context to the error message.

TigerWalts
Автор

Your videos are really great. I've started using type hinting and data classes because of your tutorials ❤

RajaseelanGaneswaran
Автор

Arjan on a mission with data classes lol OOP ftw 🔥🔥

MrAjiii
Автор

Isn't it a bit too much love to dataclasses?

ManInSombrero
Автор

Thanks! I did not realize one can use dataclass for exception handling - so beautiful!

AndrewZhilenko
Автор

Hi Arjan, if you happen to see this, would you be able to make a video on oop specifically for data transformations and loading? I never learned anything but notebooks in school and now I'm in over my head moving a simple notebook etl over to an oop style etl consuming from an api and loading to big query. If not, no worries! Thank you for all the amazing content, I'm learning so much from you!

twentytwentyeight
Автор

That's awesome Arjan. I didn't know that! Very useful

hcubill
Автор

Awesome! I was just literally looking up your other video on these :) Glad you're wearing hoodies again too Arjan.

bigutubefan
Автор

Never thought about it. Huh! Thanks for the video 😎😎

HIMixoid
Автор

0:33 Or you could have inherited from ValueError.

lawrencedoliveiro
Автор

Arjan, why do you use only dataclasses everywhere? Regular classes are somehow obsolete or do you just find dataclasses more readable?

kovalensue
Автор

How do you now see the associated information of the error? Is it printed out as well when you throw the new error type? And if so, what mechanism does that work by?

spaghettiking
Автор

Would it make sense to have the custom exception extend ValueError instead ?

ke_
Автор

Should we separate validation from implementation in a take holiday method?

nateriver
Автор

When creating a custom exception class, I am often at doubts from which base class I should inherit. Should it be Exception or for example ValueError? Could you make a video about this problem of propose some solution and guidelines?

vladimirkraus
Автор

@arjanCodes Do you have the code on github for these youtube short videos?

iphoneman
Автор

Would using dataclasses to create a linked list make sense?

BradleyBell
Автор

I would make the inheritance of a new custom error from ValueError instead of Exception, so that the whole set of possible validation errors could be caught by a higher level.

igor_sereda
visit shbcf.ru