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
My goal is for error objects to have codes attached. My preferred way is one defined by the module creating the error, which may be an enum.
// Module myMod
public type ErrorCode {
.notFound(path: String)
.accessDenied
}
// A user of 'myMod' could check like:
when err.code {
.notFound(path) -> ...
.accessDenied -> ...
}
a. Make Error an interface, similar to Go, with the message as a String field, and a code (Any type). Also, should they be fields, or methods (so structs can compute messages; but that could also be done by an initializer)?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Erroran interface, similar to Go, with the message as a String field, and a code (Anytype). Also, should they be fields, or methods (so structs can compute messages; but that could also be done by an initializer)?Errora structAll reactions