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

  • SEARCH
  • Home
  • 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 9134857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:44:16+00:00 2026-06-17T08:44:16+00:00

Possible Duplicate: JavaScript Exception Handling I have a web application where 100% of the

  • 0

Possible Duplicate:
JavaScript Exception Handling

I have a web application where 100% of the javascript code executes as jQuery event handlers (I guess most jQuery apps are like this).

The question is how can I define a global exception handler. That is, if a function that is called when any exception that happens within any jQuery event handler goes uncaught (whether it is onload, click, a succesfull ajax call, an ajax error, whatever).
My function would receive the error info (exception, stacktrace, whatever).

Clarification: I don’t mean globally catching in ajax problems generated by the server or network, but globally catching problems that are due to (presumably) bugs in our code.

  • 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-06-17T08:44:17+00:00Added an answer on June 17, 2026 at 8:44 am

    I guess this can be achieved using concepts from the Aspect-oriented programming.

    We can simply create a wrapper of jQuery.event.dispatch which will handle the errors:

    (function () {
        var temp = jQuery.event.handle;
        jQuery.event.handle = function () {
           try {
              temp.apply(this, arguments);
           } catch (e) {
              console.log('Error while dispatching the event.');
           }
        }
    }());
    $(document).click(function () {
        throw 'Some error...';
    });
    

    Using this approach you must be very careful because of changes in the internal interface

    • Note the example above works for jQuery v1.6.3, in jQuery 1.7.1 jQuery.event.dispatch instead of jQuery.event.handle.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: $(document).ready equivalent without jQuery I have a framework-less javascript that executes on
Possible Duplicate: How to catch exceptions in javascript? I am changing old web application.
Possible Duplicate: Javascript or Jquery to check and uncheck all checkbox I have 12
Possible Duplicate: JavaScript Function Definition in ASP User Control Hi, I have a generic
Possible Duplicate: Javascript Closure Problem In the following code, TrueThis.aChoices[i]['CallBack'] is a function when
Possible Duplicate: Javascript syntax: what comma means? I came across the code while reading
Possible Duplicate: Javascript color gradient I have color one (let's say yellow) and color
Possible Duplicate: How do I trim a string in javascript? I have below string
Possible Duplicate: javascript (jquery) calendar plugin I am going to develop the weekly calendar
Possible Duplicate: JavaScript property access: dot notation vs. brackets? Let's consider I have an

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.