Issues related to use of TransportException
See original GitHub issueLagom Version (2.5.x / etc)
Lagom 1.3.0-RC1
API (Scala / Java / Neither / Both)
Scala
There are several minor annoyances related to using TransportException
, e.g. to return NotFound
results. I’m happy to submit a PR with the appropriate changes if I can get some feedback about the most desirable approaches:
- (#1247) The use of
getClass
in theTransportException
constructor results in theExceptionMessage
name being set to"Predef$"
. This doesn’t affect the built-in exceptions since they explicitly passclassOf[X].getSimpleName
as the name, but it affects subclasses ofTransportException
which use the default constructors, e.g. this test fails:
import com.lightbend.lagom.scaladsl.api.transport.{TransportErrorCode, TransportException}
import org.scalatest.WordSpec
class ResponseExceptionsSpec extends WordSpec {
"TransportException" should {
"not use Predef$ as the exception name" in {
val e = new TransportException(TransportErrorCode.NotFound, "Not found")
assert(e.exceptionMessage.name != "Predef$")
}
}
}
-
It is often not desirable to log a
TransportException
, e.g.ScaladslServiceRouter
overridesmaybeLogException
to not logNotFound
when a service call throws it. However, there is no way to extend this to an app’s ownTransportException
subclasses sinceLagomServerBuilder
is final, and it always constructs aScaladslServiceRouter
. Possible solutions could be:- Provide an option to ignore all
TransportExceptions
(other than the ones being reported as warnings) - Introduce a marker trait which could indicate that the exception is not to be logged
- Allow the router to be specified by the application so that
maybeLogException
can be overridden with custom logic.
- Provide an option to ignore all
-
(almost done in #1247) The built-in
TransportExceptions
don’t provide any tests for equality, so returning them from a PersistentEntity causes the PersistentEntityTestDriver to report that they are not the same before/after serialization/deserialization. E.g.
org.scalatest.exceptions.TestFailedException: Vector(Object [com.lightbend.lagom.scaladsl.api.transport.NotFound: not found (TransportErrorCodeImpl(404,1008,Policy Violation))] does not equal [com.lightbend.lagom.scaladsl.api.transport.NotFound: not found (TransportErrorCodeImpl(404,1008,Policy Violation))] after serialization/deserialization) had length 1 instead of expected length 0
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:8 (6 by maintainers)
Top GitHub Comments
#1247 doesn’t fix the third item. I think a TODO was left for this https://github.com/lagom/lagom/pull/1247/files#r173299260
@notNotDaniel I edited the original description so your list is now a todo list. Also added a ref to the PR fixing the first item as @TimMoore pointed out.