Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6113689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:53:16+00:00 2026-05-23T14:53:16+00:00

try/catch can not handle errors in asynchronous functions. Of course, it is possible to

  • 0

try/catch can not handle errors in asynchronous functions.
Of course, it is possible to handle if I write try/catch in the every asynchronous functions but it is not realistic.

window.onerror can handle errors in asynchronous functions.
But window.onerror catches all errors in the window.
I just want handle all the errors only in asynchronous(and also synchronous) functions of a javascript application(for example, game) in the window.
And if a error occurs only in the javascript application, I want to show a error message and stop the application.
I want to do nothing for errors out of the application.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:53:17+00:00Added an answer on May 23, 2026 at 2:53 pm

    It sounds like it won’t be possible to distinguish between script errors and other errors. If you just want to catch your own exception types, then you could define a custom Exception constructor and derive all of your own exceptions from that. Then have window.onerror check to see if the object is derived from your custom constructor (and return true if so, to suppress the error, or otherwise return false).

    I think the most robust way of doing this would be to surround each async function in a try/catch (even though you say you don’t want to do this). You can just make this an idiom; surround each async function in a try/catch and have the catch block call a function that handles the error appropriately. Or better yet, make an idiom where the async function takes an additional “failure” callback, which it calls if an error occurs. That way, the caller of an async function can specify an asynchronous error handler. (This approach is used by the GWT framework, for one thing.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to catch as many errors as possible in PHP and properly handle
We are using SQL 2005 and the try-catch functionality to handle all of our
I know its probably possible, but is it practical and doable to try and
I know its probably possible, but is it practical and doable to try and
so I'm not entirely sure this is possible, but I am curious if it
Short of inserting a try/catch block in each worker thread method, is there a
I'm bored with surrounding code with try catch like this.. try { //some boring
So, I know that try/catch does add some overhead and therefore isn't a good
What kind of performance implications are there to consider when using try-catch statements in
Should I always wrap external resource calls in a try-catch? (ie. calls to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.