diff --git a/src/main/scala/com/rawlabs/das/server/DASSdkManager.scala b/src/main/scala/com/rawlabs/das/server/DASSdkManager.scala index 85d2a8c..a0db8f1 100644 --- a/src/main/scala/com/rawlabs/das/server/DASSdkManager.scala +++ b/src/main/scala/com/rawlabs/das/server/DASSdkManager.scala @@ -99,7 +99,10 @@ class DASSdkManager(implicit settings: RawSettings) extends StrictLogging { def getDAS(dasId: DASId): DASSdk = { dasSdksInMemoryLock.synchronized { logger.debug(s"Fetching DAS with ID: $dasId") - dasSdksInMemory.getOrElseUpdate(dasId, getDASFromRemote(dasId)) + dasSdksInMemory.getOrElseUpdate( + dasId, + getDASFromRemote(dasId).getOrElse(throw new IllegalArgumentException(s"DAS not found: $dasId")) + ) } } @@ -166,10 +169,8 @@ class DASSdkManager(implicit settings: RawSettings) extends StrictLogging { * @param dasId The DAS ID to retrieve. * @return The DAS instance. */ - private def getDASFromRemote(dasId: DASId): DASSdk = { - logger.error(s"getDASFromRemote not implemented for DAS ID: $dasId") - // TODO: Implement this method - go to creds to get the definition - throw new NotImplementedError("getDASFromRemote not implemented") + private def getDASFromRemote(dasId: DASId): Option[DASSdk] = { + None } } diff --git a/src/main/scala/com/rawlabs/das/server/DASServer.scala b/src/main/scala/com/rawlabs/das/server/DASServer.scala index f4bfd3b..cf1cc2f 100644 --- a/src/main/scala/com/rawlabs/das/server/DASServer.scala +++ b/src/main/scala/com/rawlabs/das/server/DASServer.scala @@ -31,7 +31,7 @@ class DASServer(implicit settings: RawSettings) { .forPort(port) .addService(registrationService) .addService(tablesService) - .intercept(new ExceptionHandlingInterceptor) + .intercept(new ThrowableHandlingInterceptor) .build() .start() } diff --git a/src/main/scala/com/rawlabs/das/server/ExceptionHandlingInterceptor.scala b/src/main/scala/com/rawlabs/das/server/ThrowableHandlingInterceptor.scala similarity index 81% rename from src/main/scala/com/rawlabs/das/server/ExceptionHandlingInterceptor.scala rename to src/main/scala/com/rawlabs/das/server/ThrowableHandlingInterceptor.scala index 3f3d7e7..c5e3359 100644 --- a/src/main/scala/com/rawlabs/das/server/ExceptionHandlingInterceptor.scala +++ b/src/main/scala/com/rawlabs/das/server/ThrowableHandlingInterceptor.scala @@ -15,7 +15,7 @@ package com.rawlabs.das.server import com.typesafe.scalalogging.StrictLogging import io.grpc._ -class ExceptionHandlingInterceptor extends ServerInterceptor with StrictLogging { +class ThrowableHandlingInterceptor extends ServerInterceptor with StrictLogging { override def interceptCall[ReqT, RespT]( call: ServerCall[ReqT, RespT], @@ -25,7 +25,7 @@ class ExceptionHandlingInterceptor extends ServerInterceptor with StrictLogging val serverCall = new ForwardingServerCall.SimpleForwardingServerCall[ReqT, RespT](call) { override def close(status: Status, trailers: Metadata): Unit = { - // Convert any exception to a gRPC status + // Convert any throwable to a gRPC status if (status.getCause != null) { val newStatus = status.withDescription(status.getCause.getMessage).withCause(status.getCause) super.close(newStatus, trailers) @@ -42,10 +42,10 @@ class ExceptionHandlingInterceptor extends ServerInterceptor with StrictLogging try { super.onHalfClose() } catch { - case ex: Exception => - logger.debug(s"Exception caught in interceptor", ex) + case t: Throwable => + logger.debug(s"Throwable caught in interceptor", t) // Close the call with an error status - serverCall.close(Status.INTERNAL.withDescription(ex.getMessage).withCause(ex), new Metadata()) + serverCall.close(Status.INTERNAL.withDescription(t.getMessage).withCause(t), new Metadata()) } } }