Skip to content
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

slf4j - cause to throwable using FiberFailure to have proper stacktrace #811

Merged
merged 1 commit into from
Feb 18, 2024

Conversation

justcoon
Copy link
Contributor

No description provided.

@justcoon justcoon requested a review from a team as a code owner February 17, 2024 17:03
/**
* convert [[zio.Cause]] to [[java.lang.Throwable]] using [[zio.FiberFailure]]
*/
val causeToThrowableDefault: Cause[Any] => Option[Throwable] = cause =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this should just be FiberFailure(cause) and return a Throwable instead of an Option[Throwable]. A Cause.empty still means some failure occurred, it just means we don't have additional information about that failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in current zio.ZLogger interface, Cause is always provided

trait ZLogger[-Message, +Output] { self =>
  def apply(
    trace: Trace,
    fiberId: FiberId,
    logLevel: LogLevel,
    message: () => Message,
    cause: Cause[Any],
    context: FiberRefs,
    spans: List[LogSpan],
    annotations: Map[String, String]
  ): Output
}

for example ZIO.logInfo("Start"):

Screenshot 2024-02-18 at 11 01 24

considering zio.Cause.isEmpty implementation, is it better in case of causeToThrowableDefault to pattern match on zio.Cause.Empty ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

@adamgfraser adamgfraser merged commit 32da7d2 into zio:master Feb 18, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants