-
Notifications
You must be signed in to change notification settings - Fork 53
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
Uniform error handling #325
Comments
@marekmaskarinec Do you mean something like the
|
Yes, something like that. However, I don't think we should just blindly copy Go. |
Proposal # 1This is approach is very similar to Go, as in it requires manual checking and returning of the errors. However, unlike in Go, the error isn't an interface, but rather an opaque struct. The examples will assume the module that implements the error handling is called Creating an error:
The module name and error number are used to distinguish errors in the program. The message is for the user/developer.
Pros:
Cons:
|
Where are the error constants defined? |
P.S. I think for |
They are defined by the programmer, probably in the module which produces the error.
The point is that it doesn't need to be just the module. It's more of an id for the group of error codes. |
Umka has no built-in error-handling functionality (except
error
). I don't mind that - some languages are designed this way. However, I'm missing a uniform way of handling errors used by Umka programs and libraries. For example, tophat and Umka's standard modules don't handle errors (if you don't count returning null). On the other hand libraries liketar
,os
, orhttp
handle errors in their incompatible way. Naturally, a problem will arise: what if I'd want to use two of those libraries at once in a function, and return an error from said function?That's why I think there should be some kind of Umka error system. In my opinion implemented as part of either
std.um
orerr.um
, not as a standalone package. Here's what I want from this system:The text was updated successfully, but these errors were encountered: