Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ospfranco committed Oct 16, 2023
1 parent 1443452 commit e5eed45
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import typeof {enable} from 'promise/setimmediate/rejection-tracking';

const LogBox = require('./LogBox/LogBox').default;
import LogBox from './LogBox/LogBox';

let rejectionTrackingOptions: $NonMaybeType<Parameters<enable>[0]> = {
allRejections: true,
Expand All @@ -25,24 +25,24 @@ let rejectionTrackingOptions: $NonMaybeType<Parameters<enable>[0]> = {
message = Error.prototype.toString.call(rejection);
const error: Error = (rejection: $FlowFixMe);

const warning =
`Possible Unhandled Promise Rejection (id: ${id}):\n` +
`${message ?? ''}\n` +
(stack == null ? '' : stack);

// Print pretty unhandled rejections while on DEV
// Print correct unhandled rejections stack while on DEV
if (__DEV__) {
LogBox.addLog({
level: 'warn',
message: {content: warning, substitutions: []},
message: {
content:
`Possible Unhandled Promise Rejection (id: ${id}):\n` +
`${message ?? ''}\n`,
substitutions: [],
},
componentStack: [],
stack: error.stack,
category: 'possible_unhandled_promise_rejection',
});

return;
} else {
console.warn(warning);
stack = error.stack;
}
} else {
try {
Expand Down

0 comments on commit e5eed45

Please sign in to comment.