33import com .fasterxml .jackson .annotation .JsonCreator ;
44import com .google .common .annotations .Beta ;
55import com .sap .ai .sdk .core .common .ClientError ;
6+ import com .sap .ai .sdk .orchestration .model .Error ;
67import com .sap .ai .sdk .orchestration .model .ErrorResponse ;
78import com .sap .ai .sdk .orchestration .model .ErrorResponseStreaming ;
9+ import com .sap .ai .sdk .orchestration .model .ErrorStreaming ;
810import javax .annotation .Nonnull ;
911import lombok .AccessLevel ;
1012import lombok .AllArgsConstructor ;
@@ -35,11 +37,9 @@ public static class Synchronous extends OrchestrationError {
3537 */
3638 @ Nonnull
3739 public String getMessage () {
38- return errorResponse .getError ().getCode () == 500
39- ? errorResponse .getError ().getMessage ()
40- + " located in "
41- + errorResponse .getError ().getLocation ()
42- : errorResponse .getError ().getMessage ();
40+ final Error e = errorResponse .getError ();
41+ final Integer code = e .getCode ();
42+ return code == 500 ? "%s located in %s" .formatted (code , e .getLocation ()) : e .getMessage ();
4343 }
4444 }
4545
@@ -60,11 +60,9 @@ public static class Streaming extends OrchestrationError {
6060 */
6161 @ Nonnull
6262 public String getMessage () {
63- return errorResponse .getError ().getCode () == 500
64- ? errorResponse .getError ().getMessage ()
65- + " located in "
66- + errorResponse .getError ().getLocation ()
67- : errorResponse .getError ().getMessage ();
63+ final ErrorStreaming e = errorResponse .getError ();
64+ final Integer code = e .getCode ();
65+ return code == 500 ? "%s located in %s" .formatted (code , e .getLocation ()) : e .getMessage ();
6866 }
6967 }
7068}
0 commit comments