Custom Errors



Custom exception classes are super simple to create and make your libraries much easier to work with for your users. For this example we are going to be working with a data api for a social blogging platform called VED.

Built in Exceptions


import ved

ved.get_articles(user='waylonwalker', per_page=2, page=1)

    "user": "waylonwalker",
    "article_id": "49202048",
    "title": "My Awesome Article"


Our First Exception

Custom Base Class

It is common courtesy to create a common base exception for all of your exceptions to derive from. This will give the users of your library more control to handling layers of your ex

πŸ‘€ see an issue, edit this post on GitHub

If you found value in this post
and want to send a tip.

Buy Me A Coffee

tweet about this post and it will show up here.

←An IndieWeb Webring πŸ•ΈπŸ’β†’