Skip to content

Commit 9425d95

Browse files
fix: [Orchestration] Added location to server errors
1 parent 5d28e0e commit 9425d95

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiError.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import lombok.AccessLevel;
99
import lombok.AllArgsConstructor;
1010
import lombok.Value;
11-
import lombok.experimental.Delegate;
1211

1312
/**
1413
* Represents an error response from the OpenAI API.
@@ -20,7 +19,6 @@
2019
@AllArgsConstructor(onConstructor = @__({@JsonCreator}), access = AccessLevel.PROTECTED)
2120
public class OpenAiError implements ClientError {
2221
/** The original error response from the OpenAI API. */
23-
@Delegate(types = {ClientError.class})
2422
ErrorResponse originalResponse;
2523

2624
/**

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import com.google.common.annotations.Beta;
55
import com.sap.ai.sdk.core.common.ClientError;
66
import com.sap.ai.sdk.orchestration.model.ErrorResponse;
7+
import javax.annotation.Nonnull;
78
import lombok.AccessLevel;
89
import lombok.AllArgsConstructor;
910
import lombok.Value;
10-
import lombok.experimental.Delegate;
1111

1212
/**
1313
* Orchestration error response.
@@ -18,6 +18,18 @@
1818
@Value
1919
@Beta
2020
public class OrchestrationError implements ClientError {
21-
@Delegate(types = {ClientError.class})
2221
ErrorResponse originalResponse;
22+
23+
/**
24+
* Gets the error message from the contained original response.
25+
*
26+
* @return the error message
27+
*/
28+
@Nonnull
29+
public String getMessage() {
30+
final String message = originalResponse.getMessage();
31+
return originalResponse.getCode() == 500
32+
? message + " in " + originalResponse.getLocation()
33+
: message;
34+
}
2335
}

0 commit comments

Comments
 (0)