Skip to content

Commit

Permalink
This will fix sentry errors with no title by using the extra info as …
Browse files Browse the repository at this point in the history
…a title (#2565)
  • Loading branch information
andrepimenta authored May 3, 2021
1 parent 7d9ea32 commit 341ce1e
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions app/util/Logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,27 @@ export default class Logger {
if (__DEV__) {
console.warn(DEBUG, error); // eslint-disable-line no-console
} else if (metricsOptIn === AGREED) {
let exception = error.error || error.message || error.originalError || error;
if (!(error instanceof Error)) {
let exception = error;

if (!error) {
if (!extra) return console.warn('No error nor extra info provided');

const typeExtra = typeof extra;
switch (typeExtra) {
case 'string':
exception = new Error(extra);
break;
case 'object':
if (extra.message) {
exception = new Error(extra.message);
} else {
exception = new Error(JSON.stringify(extra));
}
break;
default:
exception = new Error('error to capture is not an error instance');
}
} else if (!(error instanceof Error)) {
const type = typeof error;
switch (type) {
case 'string':
Expand Down

0 comments on commit 341ce1e

Please sign in to comment.