-
Notifications
You must be signed in to change notification settings - Fork 54
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
Print methods of the Console
effect should not depend on Abort[IOException]
#1037
Comments
Or rather, in the relevant |
I think here we need a decision by @fwbrasil By the way, since the exception suppression was intentional, I would give hope to Java designers. Do you want your whole application to stop working because you can't write logs? There are cases when I would say yes and cases when I would say no 🤷♂️. |
The problem is that we've not thrown public void write(int b) {
try {
if (lock != null) {
lock.lock();
try {
implWrite(b);
} finally {
lock.unlock();
}
} else {
synchronized (this) {
implWrite(b);
}
}
}
catch (InterruptedIOException x) {
Thread.currentThread().interrupt();
}
catch (IOException x) {
trouble = true;
}
} We would need a dedicated domain error. |
That should be up to the application developer. I believe it's trivial to suppress/ignore errors in Kyo. But for that to happen, the errors must not be hidden from the application developer in the first place. |
You're right. The only concern is that we cannot access the original |
This is interesting. Looks like |
I agree with dropping the pending |
I can work on this 😄 |
That may be true. But that doesn't change the fact that errors may happen. And if the Kyo signature doesn't reflect this, then it's lying to its users.
True, but the underlying implementation itself is designed in a ways which is misleading to its users.
All the work to build this sophisticated effect tracking system, only to not use it when needed? :)
Isn't |
I think @fwbrasil was suggesting that we have a set of Console methods that
work like the standard Java methods (i.e., they swallow errors) and a
second set of methods that expose errors using `Abort[IOException]`.
…On Thu, Jan 23, 2025 at 6:13 AM Ondra Pelech ***@***.***> wrote:
this is the behavior they are used to and will be expecting
That may be true. But that doesn't change the fact that errors may happen.
And if the Kyo signature doesn't reflect this, then it's lying to its users.
matches the behavior of the underlying implementation
True, but the underlying implementation itself is designed in a ways which
is misleading to its users.
simplifies effect tracking
All the work to build this sophisticated effect tracking system, only to
not use it when needed? :)
It'd be nice to also expose a method to check for errors
Isn't Abort[...] precisely such Kyo-idiomatic way to check for these
errors?
—
Reply to this email directly, view it on GitHub
<#1037 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGEA2MK7BOSUXMY4CY3HQWL2MDFGZAVCNFSM6AAAAABVRDHXF2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMBZGUZTGOBSHE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Despite the final solution, we need to fix the current implementation since it's saying it can fail with an |
I had in mind exposing a single method like
To be frank, for some time I wasn't even convinced that tracking failures in Kyo's APIs made sense. This is a good example since people have been using these Java APIs for many years. I imagine the vast majority don't know of this quirk and it didn't even matter. I can see more value in tracking failures now, especially given Kyo's more flexible support allowing proper handling of specific failures, but I don't see it as a all-or-nothing decision. In the case of |
@hearnadam could you share your thoughts on this? |
Given the precedence of Java doing the 'wrong' thing, we probably should too. Yes, it would be 'optimal' in some senses to do the right thing (validating the program works as expected/ensuring output), however I think the usability concern of debugging/newcomers is reasonable. I wouldn't expect production projects to use |
Thanks to everybody for sharing his point of view, so, summing up:
Is it correct? |
Yes, I think that's it. About |
Ok, let's do it! |
@rcardin are you still interested in PR'ing this? |
Yep, sorry, I’m having a busy week. Do we have a deadline? |
No, take your time! |
I will try to open the PR at the latest by this Friday |
The Scala
Console.println
doesn't throw anIOException
. The method uses the JavaPrintStream
type, which fails silently in case of errors. So, thekyo.Console
effect should not depend upon anAbort[IOException]
for printing text on the console.We should rewrite the code such that the examples in the documentation will change accordingly:
See PrintWriter and PrintStream never throw IOExceptions for further details.
The text was updated successfully, but these errors were encountered: