Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: adding common fault Error into standard lib #1984

Open
alexveden opened this issue Feb 18, 2025 · 0 comments
Open

Feature request: adding common fault Error into standard lib #1984

alexveden opened this issue Feb 18, 2025 · 0 comments

Comments

@alexveden
Copy link
Contributor

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:

  1. Argument error - parameter of a function didn't pass sanity check, this could be applicable to console args parsing too.
  2. Memory error - out of memory.
  3. Overflow error - buffer overflow, number overflow, math overflow.
  4. NotFound error - something is not existing, missing stuff
  5. Index error - array, data, index error or out of bounds
  6. Already exists - something what you are trying to make is already exists
  7. KeyError - key is not found or adding same key name
  8. ValueError - value of the thing is bad, or maybe math operation error.
  9. OS Error / System Error - OS API or general error
  10. IO error - general IO error
  11. Stop Iterator error - for supporting non-bound iterators while(try item = iterator.next()) stopping
  12. Runtime error - some general purpose error

Some more specific but also useful:

  1. Connection error - DB, network, device connection error
  2. Timeout - timer timeout, socket timeout, etc.
  3. Access/Permission error - file, resource, device access error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant