Show error if method fails in tools

This commit is contained in:
Jim Hamill
2025-03-15 05:08:38 +00:00
parent 0276630776
commit cb7e3cc6a5
@@ -69,7 +69,7 @@
type="text"
v-model="state.selectedMethod.models[i]"
/>
<div v-if="state.error" class="text-error">{{ state.error }}</div>
<div v-if="state.selectedMethod.error" class="text-error">{{ state.selectedMethod.error }}</div>
</div>
</template>
</div>
@@ -131,6 +131,9 @@ export interface Method<Primitive> {
// Result of method execution,
result?: string;
// Error (if one occurred).
error?: string;
// Function that takes the models and returns the primitive
callback: (primitive: Primitive, value: Array<any>) => string;
@@ -222,7 +225,11 @@ async function executeMethod(wrappedMethod: () => string | Promise<string>): str
}
state.value.selectedMethod.result = await wrappedMethod;
state.value.selectedMethod.error = undefined;
} catch(error: any) {
state.value.selectedMethod.error = error.message;
return error.message;
}
};