Are custom exception types automatically serializable in a StatusReply?

If I create my own exception object/class/type, e.g.

case object MyError extends Throwable
case class MyOtherError(msg: String) extends Throwable("the other error")

And then send these errors in a clustered system that has java-serialization disabled and uses custom serializers:

val ex1 = MyError
val ex2 = MyOtherError("user not found")
actorRef1 ! StatusReply.error(ex)
actorRef2 ! StatusReply.error(ex2)

Will my custom errors fail to be serialized? Or is the built in serializer for StatusReply able to serialize MyError and MyOtherError?

I see that in the StatusReply.error api it says: “Also note that Akka does not contain pre-build serializers for arbitrary exceptions.”

But I also see in the generic response wrapper documentation it says “Akka includes pre-built serializers for the type, so in the normal use case a clustered application only needs to provide a serializer for the successful result.” (my emphasis).

So would this work or would I need to define and link custom serializers for MyError and MyOtherError?

akka/akka-remote/src/main/scala/akka/remote/serialization/MiscMessageSerializer.scala at 1054cc8eb9c96d013d5c2cde0be8292f92f909e0 · akka/akka · GitHub is how the StatusReplys are serialized.

Note that the recommended usage is to not send the full exception across the wire, but just a string message (the full exception is somewhat akin to leaking a full exception and stacktrace in a web UI); the generic response wrapper docs only illustrate sending a string. But if a custom exception is an effective way of including useful data for an asker (e.g. “there’s no point in retrying before this time”), you would have to register a serializer for the exception and then the exception will be serialized.