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/client/lib/utils/callWithErrorHandling.ts

19 lines
461 B

import {
ServerMethodName,
ServerMethodParameters,
ServerMethodReturn,
} from '../../contexts/ServerContext';
import { call } from './call';
import { handleError } from './handleError';
export const callWithErrorHandling = async <M extends ServerMethodName>(
method: M,
...params: ServerMethodParameters<M>
): Promise<ServerMethodReturn<M>> => {
try {
return await call(method, ...params);
} catch (error) {
handleError(error);
throw error;
}
};