@@ -764,33 +764,39 @@ private static int mapErrorToHttpStatus(A2AError error) {
764764 return errorCode .httpCode ();
765765 }
766766 if (error instanceof InvalidParamsError ) {
767- return 422 ;
767+ return A2AErrorCodes . INVALID_PARAMS . httpCode () ;
768768 }
769- if (error instanceof MethodNotFoundError || error instanceof TaskNotFoundError ) {
770- return 404 ;
769+ if (error instanceof MethodNotFoundError ) {
770+ return A2AErrorCodes .METHOD_NOT_FOUND .httpCode ();
771+ }
772+ if (error instanceof TaskNotFoundError ) {
773+ return A2AErrorCodes .TASK_NOT_FOUND .httpCode ();
771774 }
772775 if (error instanceof TaskNotCancelableError ) {
773- return 409 ;
776+ return A2AErrorCodes . TASK_NOT_CANCELABLE . httpCode () ;
774777 }
775778 if (error instanceof UnsupportedOperationError ) {
776- return 501 ;
779+ return A2AErrorCodes . UNSUPPORTED_OPERATION . httpCode () ;
777780 }
778781 if (error instanceof ContentTypeNotSupportedError ) {
779- return 415 ;
782+ return A2AErrorCodes . CONTENT_TYPE_NOT_SUPPORTED . httpCode () ;
780783 }
781784 if (error instanceof InvalidAgentResponseError ) {
782- return 502 ;
785+ return A2AErrorCodes .INVALID_AGENT_RESPONSE .httpCode ();
786+ }
787+ if (error instanceof ExtendedAgentCardNotConfiguredError ) {
788+ return A2AErrorCodes .EXTENDED_AGENT_CARD_NOT_CONFIGURED .httpCode ();
789+ }
790+ if (error instanceof ExtensionSupportRequiredError ) {
791+ return A2AErrorCodes .EXTENSION_SUPPORT_REQUIRED .httpCode ();
783792 }
784- if (error instanceof ExtendedAgentCardNotConfiguredError
785- || error instanceof ExtensionSupportRequiredError
786- || error instanceof VersionNotSupportedError
787- || error instanceof PushNotificationNotSupportedError ) {
788- return 400 ;
793+ if (error instanceof VersionNotSupportedError ) {
794+ return A2AErrorCodes .VERSION_NOT_SUPPORTED .httpCode ();
789795 }
790- if (error instanceof InternalError ) {
791- return 500 ;
796+ if (error instanceof PushNotificationNotSupportedError ) {
797+ return A2AErrorCodes . PUSH_NOTIFICATION_NOT_SUPPORTED . httpCode () ;
792798 }
793- return 500 ;
799+ return A2AErrorCodes . INTERNAL . httpCode () ;
794800 }
795801
796802 /**
0 commit comments