-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
Automatic error logging #2664
Comments
I think Loggers should probably just be extended to have better support for |
I would think it not to be best to have the |
That's what I mean, yeah. I think all loggers, logDebug, etc. should have better support for logging an instance of an |
Ah, ok! I think that could be cool, yeah! |
They already have good support for effect.pipe(Effect.tapErrorCause(Effect.logError)) |
@MrOxMasTer there is no "ideology of |
There is only one question. Why isn't there a function that would also look through errors (for example, for logging) and they wouldn't have to be returned. If you look at the words from the documentation: I can change the number of errors, but not the errors themselves of course. This seems both thoughtful and strange at the same time |
You cannot. It will be only 1 or 0. A union is not an array. What you accumulate is the type of a potential error.
It does not alter the error. What you're experiencing is erroring while processing an error. Analogue to saying that this function is 'altering the error' function bar() {
throw new Error("dang")
}
try {
foo()
} catch (e) {
bar()
} The error is effectively swallowed in these conditions, but that's expected. What you're probably confused about is the track switching. You don't need to return a failed Effect just because you're working on the failed channel. Effect.tapError((error) => {
// Your own code
// you can return any effect you want to execute.
// its value would be discarded, like `tap`.
// Its failures would halt execution, like `tap`.
// except that it resolving successfully does not count as 'recovering' from the failure.
return Effect.succeed(10)
return Effect.sync(() => {..})
return Effect.flatMap(someEffect, someOtherEffect)
return Effect.void
}) Now I will ask again, please if you have any questions reach out to our discord. We are being unfair to the OP and collaborators by hijacking the thread like this, I would not answer any followups here, I will gladly do so on discord. Hope this clears things up a bit. |
What is the problem this feature would solve?
More convenient logging for errors.
What is the feature you are proposing to solve the problem?
ZIO has the below
logError
function, which will automatically log if thethis
ZIO element is an error.Effect
also has alogError
function which works completely differently. That's fine, but it would also be nice to have a function like the one above which will just automatically log any error for me.What alternatives have you considered?
No response
The text was updated successfully, but these errors were encountered: