@@ -132,12 +132,10 @@ private Map<String, Object> extractToolArguments(String toolInput) {
132132 return JsonParser .fromJson (toolInput , new TypeReference <>() {
133133 });
134134 }
135- catch (IllegalStateException ex ) {
136- if (ex .getCause () instanceof JsonProcessingException jsonExp ) {
137- logger .warn ("Conversion from JSON failed" , ex );
138- throw new ToolExecutionException (this .getToolDefinition (), jsonExp );
139- }
140- throw ex ;
135+ catch (Exception ex ) {
136+ logger .warn ("Conversion from JSON failed" , ex );
137+ Throwable cause = (ex .getCause () instanceof JsonProcessingException ) ? ex .getCause () : ex ;
138+ throw new ToolExecutionException (this .getToolDefinition (), cause );
141139 }
142140 }
143141
@@ -168,12 +166,10 @@ private Object buildTypedArgument(@Nullable Object value, Type type) {
168166 String json = JsonParser .toJson (value );
169167 return JsonParser .fromJson (json , type );
170168 }
171- catch (IllegalStateException ex ) {
172- if (ex .getCause () instanceof JsonProcessingException jsonExp ) {
173- logger .warn ("Conversion from JSON failed" , ex );
174- throw new ToolExecutionException (this .getToolDefinition (), jsonExp );
175- }
176- throw ex ;
169+ catch (Exception ex ) {
170+ logger .warn ("Conversion from JSON failed" , ex );
171+ Throwable cause = (ex .getCause () instanceof JsonProcessingException ) ? ex .getCause () : ex ;
172+ throw new ToolExecutionException (this .getToolDefinition (), cause );
177173 }
178174 }
179175
0 commit comments