Skip to content

Commit 9022352

Browse files
committed
Minor syntax improvement
1 parent 07c3e57 commit 9022352

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationError.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import com.fasterxml.jackson.annotation.JsonCreator;
44
import com.google.common.annotations.Beta;
55
import com.sap.ai.sdk.core.common.ClientError;
6+
import com.sap.ai.sdk.orchestration.model.Error;
67
import com.sap.ai.sdk.orchestration.model.ErrorResponse;
78
import com.sap.ai.sdk.orchestration.model.ErrorResponseStreaming;
9+
import com.sap.ai.sdk.orchestration.model.ErrorStreaming;
810
import javax.annotation.Nonnull;
911
import lombok.AccessLevel;
1012
import 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

Comments
 (0)