Skip to content

Latest commit

 

History

History
23 lines (19 loc) · 511 Bytes

error.md

File metadata and controls

23 lines (19 loc) · 511 Bytes

Error

Uncaught promise errors in Chrome

window.onunhandledrejection = (event) => {
  event.preventDefault(); // prevent the console.error warining
  console.log("Unhandled promise rejection: " + event.reason);
};
window.onrejectionhandled = (event) => {
  console.log("promise rejection handled");
};

function foo() {
  const promise = Promise.reject(new Error("trichobezoar"));
  setTimeout(
    () => promise.catch((error) => console.log("eventually caught")),
    5000
  );
}

foo();