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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:50:18+00:00 2026-06-01T20:50:18+00:00

Question Is there a way to trigger a custom Javascript error message? In Chrome,

  • 0

Question

Is there a way to trigger a custom Javascript error message? In Chrome, I have found console.warn[error,log] for sending messages to the browser. However, this only works in Chrome (and possibly Firefox). This line itself triggers an error in Internet explorer, though.

I’d like to be able to trigger errors that violate the rules of the Javascript function. For example, a function that takes an object as a value expects the object to have an attribute of “dialog”. If that attribute doesn’t exist, I want to trigger an error message “Modal Window: No dialog id specified.”

Context

I am building a PHP class and Javascript class that works together so that programmers of our application can easily create dialog boxes that will be uniform and reliable.


Example Code

try {
    if (!params || !params['dialog']) {
        throw "NoDID";
    }
}
catch (error) {
    if (error == "NoDID") {
        //com.MySITE.js.warn("Modal Window: No dialog id specified.");
        //Trigger custom error message here.
    }
}

I’d like the message to go to the javascript window for easy developer debugging. Just doing “throw” results in “Uncaught Custom Error Message”. I don’t want the user to see this in anything on the page. I want it available in the js log for developer use.

  • 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-01T20:50:20+00:00Added an answer on June 1, 2026 at 8:50 pm
    if (console) console.warn(...
    

    (Or you could use console.error, console.log, console.trace, etc.). Alternatively you could also do:

    console && console.warn(...
    

    Or, if you don’t like checking for console everywhere you could, at the start of your code, do:

    window.console = console || {warn: function(){}};
    

    In other words, if the browser doesn’t have a console, make a fake one with a fake “warn” method that does nothing. If you do this, you can do console.warn throughout your code without worrying about whether the browser has a console or not.

    Yet another approach would be to make your own warn method:

    function warn(message) {
        console && console.warn(message);
    }
    

    and then you could just do warn(“something went wrong”).

    Of course, if you want to actually find out when an IE user gets a user, you’ll need to instead make your own warn message, which would have to make an AJAX request to somewhere on the server (and that somewhere would then send you an email or something).

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

Sidebar

Related Questions

Group, I have a quick question? -Is there a way to trigger this onclick
I have a very theoretical question: Is there a way to ban the use
I there ANY way in javascript that we could trigger a select element (dropdown
Is there a way in jQuery or javascript to trigger a variable string as
So, like the question specifies, is there a way to trigger a mousemove event
Question Is there a way to define a method only once in C# (in
Question: Is there a way to check if a given font is one of
Silly question - Is there a way to download the iPhone SDK without Xcode
Possible duplicate question: Is there a way to indefinitely pause a thread? In my
The real question: Is there a way to clear certain attributes for all components

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.