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/packages/apps-engine/deno-runtime/lib/accessors/formatResponseErrorHandler.ts

14 lines
428 B

import { ErrorObject } from 'jsonrpc-lite';
// deno-lint-ignore no-explicit-any -- that is the type we get from `catch`
export const formatErrorResponse = (error: any): Error => {
if (error instanceof ErrorObject || typeof error?.error?.message === 'string') {
return new Error(error.error.message);
}
if (error instanceof Error) {
return error;
}
return new Error('An unknown error occurred', { cause: error });
};