File tree Expand file tree Collapse file tree 5 files changed +26
-19
lines changed
src/main/java/com/sap/ai/sdk/core/commons
foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model
orchestration/src/main/java/com/sap/ai/sdk/orchestration Expand file tree Collapse file tree 5 files changed +26
-19
lines changed Original file line number Diff line number Diff line change 3131 <properties >
3232 <project .rootdir>${project.basedir} /../</project .rootdir>
3333 <coverage .complexity>60%</coverage .complexity>
34- <coverage .line>70 %</coverage .line>
34+ <coverage .line>69 %</coverage .line>
3535 <coverage .instruction>68%</coverage .instruction>
3636 <coverage .branch>52%</coverage .branch>
3737 <coverage .method>73%</coverage .method>
Original file line number Diff line number Diff line change 11package com .sap .ai .sdk .core .commons ;
22
33import com .google .common .annotations .Beta ;
4- import javax .annotation .Nonnull ;
4+ import javax .annotation .Nullable ;
55
66/**
77 * Generic class that contains a JSON error response.
@@ -16,6 +16,6 @@ public interface ClientError {
1616 *
1717 * @return The error message
1818 */
19- @ Nonnull
19+ @ Nullable
2020 String getMessage ();
2121}
Original file line number Diff line number Diff line change 88import io .vavr .control .Try ;
99import java .io .IOException ;
1010import java .nio .charset .StandardCharsets ;
11+ import java .util .Objects ;
1112import java .util .function .BiFunction ;
1213import javax .annotation .Nonnull ;
1314import lombok .RequiredArgsConstructor ;
@@ -131,9 +132,8 @@ public void parseErrorAndThrow(
131132 throw baseException ;
132133 }
133134
134- throw exceptionType .apply (
135- "%s and error message: '%s'"
136- .formatted (baseException .getMessage (), maybeError .get ().getMessage ()),
137- null );
135+ val error = Objects .requireNonNullElse (maybeError .get ().getMessage (), "" );
136+ val message = "%s and error message: '%s'" .formatted (baseException .getMessage (), error );
137+ throw exceptionType .apply (message , baseException );
138138 }
139139}
Original file line number Diff line number Diff line change 33import com .fasterxml .jackson .annotation .JsonProperty ;
44import com .google .common .annotations .Beta ;
55import com .sap .ai .sdk .core .commons .ClientError ;
6- import javax .annotation .Nonnull ;
76import javax .annotation .Nullable ;
87import lombok .EqualsAndHashCode ;
98import lombok .Getter ;
109import lombok .ToString ;
1110import lombok .experimental .Accessors ;
11+ import lombok .experimental .Delegate ;
1212
1313/** OpenAI error. */
1414@ Accessors (chain = true )
@@ -19,12 +19,6 @@ public class OpenAiError implements ClientError {
1919 /** The error object. */
2020 @ JsonProperty ("error" )
2121 @ Getter (onMethod_ = @ Nullable )
22+ @ Delegate (types = {ClientError .class })
2223 private OpenAiErrorBase error ;
23-
24- @ Nonnull
25- @ Override
26- public String getMessage () {
27- final String message = error .getMessage ();
28- return message == null ? "" : message ;
29- }
3024}
Original file line number Diff line number Diff line change 11package com .sap .ai .sdk .orchestration ;
22
3+ import com .fasterxml .jackson .annotation .JsonCreator ;
4+ import com .google .common .annotations .Beta ;
35import com .sap .ai .sdk .core .commons .ClientError ;
46import com .sap .ai .sdk .orchestration .model .ErrorResponse ;
7+ import lombok .AccessLevel ;
8+ import lombok .AllArgsConstructor ;
9+ import lombok .Value ;
10+ import lombok .experimental .Delegate ;
511
6- /** Orchestration error response. */
7- // CHECKSTYLE:OFF
8- public class OrchestrationError extends ErrorResponse implements ClientError {}
9- // CHECKSTYLE:ON
12+ /**
13+ * Orchestration error response.
14+ * @since 1.1.0
15+ */
16+ @ AllArgsConstructor (onConstructor = @ __ ({@ JsonCreator }), access = AccessLevel .PROTECTED )
17+ @ Value
18+ @ Beta
19+ public class OrchestrationError implements ClientError {
20+ @ Delegate (types = {ClientError .class })
21+ ErrorResponse originalResponse ;
22+ }
You can’t perform that action at this time.
0 commit comments