-
Notifications
You must be signed in to change notification settings - Fork 57
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
[data] introduce Environment and improve KyoException #1057
Conversation
Option(message) match | ||
case Some(message) => message.toString; | ||
case _ => null, | ||
class KyoException private[kyo] (message: Text = "", cause: Text | Throwable = "")(using val frame: Frame) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fall back to empty string instead of null
object Environment: | ||
|
||
def isDevelopment(): Boolean = | ||
sys.props.get("kyo.development-mode.enable").map(_.toLowerCase) match |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
development can also be enabled explicitly via the kyo.development-mode.enable
system property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this. What would you think about kyo.development
?
cause match | ||
case cause: Throwable => cause; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙀 is the ;
the cause of the trouble? I'm so sorry 😿
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's harmless :)
val msg = frame.render(("⚠️ KyoException".red.bold :: Maybe(message).toList ::: detail.toList).map(_.show)*) | ||
s"\n$msg\n" | ||
else | ||
detail.map(_.toString).getOrElse(null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about .fold("")(_.take(1000).toString)
?
Co-authored-by: Ondra Pelech <[email protected]>
Problem
KyoException
is too verbose in production environments. It's designed to improve the development experience by showing errors with theFrame
information but, in a production environment, the overhead to log failures can significantly contribute to performance degradation.Solution
Introduce
Environment
that enables the verbose mode only if the user explicitly enables the development mode or sbt entries are present in the classpath, which should be the case for Kyo development environments since we recommend both sbt and metals. The risk of false positives seems low since the check is strict.Notes
I've also improved
KyoException
because I noticed aNullPointerException
.