Merge branch 'docs_add_error_if_method_fails' into 'development'
Show error if method fails in tools See merge request GeneralProtocols/xo/stack!44
This commit is contained in:
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user