You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found that I need to implement custom error type for some common cases like index error, or collection overflow, or bad argument myself. Maybe it would be more convenient to have something common in standard lib?
The main idea is to make vague error classes, for example: for a function which opens a file by path it could fail when file not found, file name is a directory, permission violation, or IO error while reading. And the caller code might not handle all tiny variations of error cases, it just wishes to know that the operation failed. So for this case, it could be useful to have a set of general purpose errors in the stdlib.
This proposal for the cases when the operation is insignificant, or error cases are too generic to make a special fail MyError class for this.
Here are some ideas of common errors:
Argument error - parameter of a function didn't pass sanity check, this could be applicable to console args parsing too.
Memory error - out of memory.
Overflow error - buffer overflow, number overflow, math overflow.
NotFound error - something is not existing, missing stuff
Index error - array, data, index error or out of bounds
Already exists - something what you are trying to make is already exists
KeyError - key is not found or adding same key name
ValueError - value of the thing is bad, or maybe math operation error.
I found that I need to implement custom error type for some common cases like index error, or collection overflow, or bad argument myself. Maybe it would be more convenient to have something common in standard lib?
The main idea is to make vague error classes, for example: for a function which opens a file by path it could fail when file not found, file name is a directory, permission violation, or IO error while reading. And the caller code might not handle all tiny variations of error cases, it just wishes to know that the operation failed. So for this case, it could be useful to have a set of general purpose errors in the stdlib.
This proposal for the cases when the operation is insignificant, or error cases are too generic to make a special
fail MyError
class for this.Here are some ideas of common errors:
while(try item = iterator.next())
stoppingSome more specific but also useful:
The text was updated successfully, but these errors were encountered: