From f8066af03e9aebd0108c8526caf93dad18e398fc Mon Sep 17 00:00:00 2001 From: NickChungSUSE Date: Thu, 19 Dec 2024 09:09:07 +0800 Subject: [PATCH] NVSHAS-9721: UI should pop up appropriate error message when user input wrong registry name correct custom exception from e.reason to e.response.enttiy of exceptionHandler --- admin/src/main/scala/com/neu/api/Api.scala | 5 +---- admin/src/main/scala/com/neu/core/ClientSslConfig.scala | 3 ++- .../csp-support-form/csp-support-form.component.ts | 2 -- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/admin/src/main/scala/com/neu/api/Api.scala b/admin/src/main/scala/com/neu/api/Api.scala index f8483fec2..726e6d312 100644 --- a/admin/src/main/scala/com/neu/api/Api.scala +++ b/admin/src/main/scala/com/neu/api/Api.scala @@ -48,10 +48,7 @@ trait Api extends Directives with CoreActors with Core { complete( HttpResponse( status = e.statusCode, - entity = HttpEntity( - e.response.entity.contentType.asInstanceOf[ContentType.NonBinary], - e.reason - ) + entity = e.response.entity ) ) case e: Exception => diff --git a/admin/src/main/scala/com/neu/core/ClientSslConfig.scala b/admin/src/main/scala/com/neu/core/ClientSslConfig.scala index ec1dbcd12..d9d64a9cd 100644 --- a/admin/src/main/scala/com/neu/core/ClientSslConfig.scala +++ b/admin/src/main/scala/com/neu/core/ClientSslConfig.scala @@ -7,6 +7,7 @@ import org.apache.pekko.http.scaladsl.Http import org.apache.pekko.http.scaladsl.HttpsConnectionContext import org.apache.pekko.http.scaladsl.model.* import org.apache.pekko.http.scaladsl.settings.ConnectionPoolSettings +import org.apache.pekko.http.scaladsl.unmarshalling.Unmarshal import org.apache.pekko.stream.Materializer import org.apache.pekko.stream.scaladsl.Sink import org.apache.pekko.stream.scaladsl.Source @@ -83,7 +84,7 @@ trait ClientSslConfig extends LazyLogging { Future.successful(response) case status => logger.info( - s"Received Response - Failure\nStatusCode: ${status.intValue()} Reason: ${status.reason()}\n$response" + s"Received Response - Failure\nStatusCode: ${status.intValue()} Reason: ${status.reason()}\n Exception: ${Unmarshal(response.entity).to[String]}" ) Future.failed(HttpResponseException(status.intValue(), status.reason(), response)) } diff --git a/admin/webapp/websrc/app/routes/settings/configuration/csp-support-form/csp-support-form.component.ts b/admin/webapp/websrc/app/routes/settings/configuration/csp-support-form/csp-support-form.component.ts index 593302e78..e499d83d1 100644 --- a/admin/webapp/websrc/app/routes/settings/configuration/csp-support-form/csp-support-form.component.ts +++ b/admin/webapp/websrc/app/routes/settings/configuration/csp-support-form/csp-support-form.component.ts @@ -5,9 +5,7 @@ import { TranslateService } from '@ngx-translate/core'; import { UtilsService } from '@common/utils/app.utils'; import { finalize } from 'rxjs/operators'; import { saveAs } from 'file-saver'; -import { GlobalConstant } from '@common/constants/global.constant'; import { NotificationService } from '@services/notification.service'; -import { ErrorResponse } from '@common/types'; import * as moment from 'moment'; @Component({