Home Machine Learning Say Goodbye to Complicated Python Error Messages | by Christopher Tao | Mar, 2024

Say Goodbye to Complicated Python Error Messages | by Christopher Tao | Mar, 2024

0
Say Goodbye to Complicated Python Error Messages | by Christopher Tao | Mar, 2024

[ad_1]

Versatile error message enhancement library — PrettyError

Programming is such an exercise that we could use 20% of our time to write down the concepts into code after which 80% to clear the errors and repair the bugs. Error messages are positively one thing we are going to see on daily basis. Nevertheless, have you ever skilled any difficulties with Python Error messages?

For instance, the error messages may be very verbose, which isn’t unhealthy, however it’s troublesome to differentiate totally different components and shortly discover the knowledge we’d like. The stack traces are additionally typically too overwhelming and complicated to know. It is usually not simple to customize the error message until we override the Exception courses, which could possibly be overwhelming once more.

On this article, I’m going to introduce a library known as PrettyError that may assist us deal with the entire ache factors talked about above and extra. It has many cool options that may streamline our debugging course of and assist us save plenty of time through the coding jobs.

Picture by Pexels from Pixabay

As typical, putting in the Fairly Error library is sort of simple. We simply merely run pip to acquire it from PyPI.

pip set up pretty_errors

A Fast Begin

That is in all probability the quickest fast begin information. After we wish to use the library with its default configuration, all we have to do is to import it earlier than coding.

import pretty_errors

Now, let’s outline a perform with out try-except in order that in a while we will manually create some errors.

def divide(a, b):
return a / b

Then, let’s first see what it appears to be like like with out Fairly Errors. We are going to simulate a division by zero error.

divide(1, 0)

[ad_2]