Imagine you come to a new project, look into the logs, and there you are mixed with successful requests for the server are the following messages:
Something constantly breaks, but silently.
If you reduce to the minimum example of what happened in the application code, which I recently began to deal with, I will get such a design that is generally not causing suspicion:
If you fulfill this example, it will turn out
UNEXPECTED Exception:
The fact is that there are four ways to display the message of the caught exception:
The first two options are not very informative. For example, if you try to turn to a non -existent dictionary key (TOP 1 Error in Python), then these options will only derive the name of the key.
This is because STR (E) and E display an exception message, but not its type. Most often, this is enough, but exceptions are needed for this to report on situations that we do not expect.
Sometimes they write Print (E.Message). There are two problems here: firstly, we still get only a message. And secondly, not all exceptions are determined by the Message attribute. If we do not provide our Print condition, then we will get only a new mistake:
But the magical method of Repr, which is needed in order to give the most accurate description, will do everything perfectly. Compare:
which is more clearly than all three options higher 🐠
HTTPS: //t. T.
#machinelearning #artificialintelligence #ai #datascience #programming #Technology #Deeplearning