diff --git a/modules/log/shared/src/main/scala/LogSpan.scala b/modules/log/shared/src/main/scala/LogSpan.scala index f5621a17..d8cb3419 100644 --- a/modules/log/shared/src/main/scala/LogSpan.scala +++ b/modules/log/shared/src/main/scala/LogSpan.scala @@ -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: _*) diff --git a/modules/log/shared/src/test/scala/LogSuite.scala b/modules/log/shared/src/test/scala/LogSuite.scala index a4115800..dc69306c 100644 --- a/modules/log/shared/src/test/scala/LogSuite.scala +++ b/modules/log/shared/src/test/scala/LogSuite.scala @@ -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" : [ | ] |} @@ -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" : [ | ] |}