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 6886191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:43:43+00:00 2026-05-27T05:43:43+00:00

In this javascript code f.init() control the entire flow of the program: var f

  • 0

In this javascript code f.init() control the entire flow of the program:

var f = function() {
    return {
        init: function(var1) {
            try {
                f.f1(1)
            } catch (e) {
                alert(e);
            }
            try {
                f.f2(1)
            } catch (e) {
                alert(e);
            }
            // ...
            // more try-catch blocks                
            // ...
        },
        f1: function() {
            throw Error('f1 called');
        },
        f2: function() {
            throw Error('f2 called');
        }
    };
}();

f.init();

How I could centralize all exceptions management in only one try-catch block? Something like this:

var f = function() {
    return {
        init: function(var1) {
            f.f1(1) // this cut the control flow if thrown some error
            f.f2(1) // so this is not called
        },
        f1: function() {
                throw Error('f1 called');
        },
        f2: function() {
                throw Error('f2 called');
        }
    };
}();

try {
    f.init();
} catch (e) {
    alert(e);
}

The previous code cut the flow after thrown some error.

  • 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-27T05:43:44+00:00Added an answer on May 27, 2026 at 5:43 am

    You can’t. Once an error is thrown, the program flow breaks.

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

Sidebar

Related Questions

This is my JavaScript code: <script> function change(name){ var element = document.all.name.value; } </script>
I have the following javascript code: function initSite(){ var site; $.getJSON(www+'init/initSite', function(data) { site
I have this JavaScript code: for (var idx in data) { var row =
How to write this JavaScript code without eval? var typeOfString = eval(typeof + that.modules[modName].varName);
I have a javascript file which has some code somewhat like this: var Slide
I have this code: <script type=text/javascript> var url = http://www.xxxxx.xxx/xxxxxxxxx; var txt; var id1;
i have some javascript code in Django templates like this <script type=text/javascript> pager.init(); pager.showPageNav('pager',
This javascript code does not work in IE8, but works in Firefox and Google
I got this javascript code from off the internet. It's a script that changes
i have this javascript code to which i want to add the jquery fade-in

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.