The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/client/lib/utils/callWithErrorHandling.ts

16 lines
536 B

import type { ServerMethodName, ServerMethodParameters, ServerMethodReturn } from '@rocket.chat/ui-contexts';
import { sdk } from '../../../app/utils/client/lib/SDKClient';
import { dispatchToastMessage } from '../toast';
export const callWithErrorHandling = async <M extends ServerMethodName>(
method: M,
...params: ServerMethodParameters<M>
): Promise<ServerMethodReturn<M>> => {
try {
return await sdk.call(method, ...params);
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
throw error;
}
};