Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async componentDidCatch(error, info) {
this.setState({ hasError: true });
const errorStack = await StackTrace.fromError(error);
await StackTrace.report(errorStack, `${URL}/user/error`, {
clientVersion,
message: error.message,
info: info?.componentStack,
token: auth()?.headers?.authorization
});
console.log(error);
}
StackTrace.fromError(error).then(stackframes => {
const stackString = stackframes
.splice(0, 20)
.map(function (sf) {
return sf.toString();
}).join('\n');
var date = moment().format('YYYY-MM-DD h:mm:ss');
message = `error :: business :: ${window['business_id']} :: studiolite :: ${date} :: ${message}`
StackTrace.report(stackString, url, message);
});
throw error;