Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function sendRequestToSlack( fn ) {
try {
await fn();
} catch ( error ) {
// Check the code property and log the response
if (
error.code === ErrorCode.PlatformError ||
error.code === ErrorCode.RequestError ||
error.code === ErrorCode.RateLimitedError ||
error.code === ErrorCode.HTTPError
) {
console.log( error.data );
} else {
// Some other error, oh no!
console.log(
'The error occurred does not match an error we are checking for in this block.'
);
console.log( error );
}
}
}