Skip to content

Commit

Permalink
Fallback to Json.Null if getMessage is null
Browse files Browse the repository at this point in the history
  • Loading branch information
daddykotex committed Apr 4, 2023
1 parent 2cdc31f commit 887a5a8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion modules/log/shared/src/main/scala/LogSpan.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private[log] final case class LogSpan[F[_]: Sync: Logger](
putAny(
"exit.case" -> "error".asJson,
"exit.error.class" -> err.getClass.getName.asJson,
"exit.error.message" -> err.toString.asJson, // toString handles null message
"exit.error.message" -> Option(err.getMessage).map(_.asJson).getOrElse(Json.Null),
"exit.error.stackTrace" -> err.getStackTrace.map(_.toString).asJson
) *> put(fields: _*)

Expand Down
4 changes: 2 additions & 2 deletions modules/log/shared/src/test/scala/LogSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class LogSuite extends CatsEffectSuite {
| ],
| "exit.case" : "succeeded",
| "exit.error.class" : "java.lang.RuntimeException",
| "exit.error.message" : "java.lang.RuntimeException: oops",
| "exit.error.message" : "oops",
| "children" : [
| ]
|}
Expand All @@ -118,7 +118,7 @@ class LogSuite extends CatsEffectSuite {
| ],
| "exit.case" : "succeeded",
| "exit.error.class" : "java.lang.RuntimeException",
| "exit.error.message" : "java.lang.RuntimeException",
| "exit.error.message" : null,
| "children" : [
| ]
|}
Expand Down

0 comments on commit 887a5a8

Please sign in to comment.