All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.udash.rpc.serialization.DefaultExceptionCodecRegistry.scala Maven / Gradle / Ivy

There is a newer version: 0.16.0
Show newest version
package io.udash.rpc.serialization

class DefaultExceptionCodecRegistry extends ClassNameBasedECR {
  override def name[T <: Throwable](ex: T): String = {
    import com.avsystem.commons._
    def find(cls: Class[_]): Opt[String] = {
      if (cls == null) Opt.Empty
      else if (codecs.contains(cls.getName)) Opt(cls.getName)
      else {
        cls.getInterfaces.iterator
          .flatMap(find)
          .filter(_.nonEmpty)
          .nextOpt
          .orElse(find(cls.getSuperclass))
      }
    }
    find(ex.getClass).getOrElse(ex.getClass.getName)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy