odin icon indicating copy to clipboard operation
odin copied to clipboard

Use `Option(t)` instead of `Some(t)`

Open danielkarch opened this issue 3 years ago • 0 comments

When passing an exception to a log statement, it is not uncommon to pass in a null value, e.g., instead of

logger.error("oh no")

sometimes

logger.error("oh no", null)

is called.

In the DefaultLogger, the passed ToThrowable[E] is turned into an Option[Throwable]. In most Scala code the expectation is that for any val t: Option[T] either t == None or t == Some(x) for x != null. With this change we avoid creating a Some(null) value if the cause to be logged is null.

danielkarch avatar Oct 04 '22 11:10 danielkarch