fix: Unseen error on client action execution
This commit is contained in:
@@ -119,7 +119,13 @@ export function actionToKBar(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function performAction(action: Action, context: ActionContext) {
|
export async function performAction(action: Action, context: ActionContext) {
|
||||||
return action.perform?.(context)?.catch((err: Error) => {
|
const result = action.perform?.(context);
|
||||||
toast.error(err.message);
|
|
||||||
});
|
if (result instanceof Promise) {
|
||||||
|
return result.catch((err: Error) => {
|
||||||
|
toast.error(err.message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ export type Action = {
|
|||||||
* Perform the action – note this should generally not be called directly, use `performAction`
|
* Perform the action – note this should generally not be called directly, use `performAction`
|
||||||
* instead. Errors will be caught and displayed to the user as a toast message.
|
* instead. Errors will be caught and displayed to the user as a toast message.
|
||||||
*/
|
*/
|
||||||
perform?: (context: ActionContext) => Promise<any> | any;
|
perform?: (context: ActionContext) => any;
|
||||||
children?: ((context: ActionContext) => Action[]) | Action[];
|
children?: ((context: ActionContext) => Action[]) | Action[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user