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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:58:38+00:00 2026-05-28T15:58:38+00:00

Somehow this does not feel like the culmination of the 50 years programming language

  • 0

Somehow this does not feel like the culmination of the 50 years programming language development:

  throw "My exception message here";

What’s the correct way to do exceptions in Javascript, so that

  • They can be identified (instanceof)

  • They can carry other payload besides the default message and stack trace

  • They “subclass” base Exception, so that debug console and such can extract meaningful information about the exception

  • Possible nested exceptions (converting exception to another): if you need to catch an exception and rethrow new one the orignal stack trace would be preserved and could be meaningfully read by debugging tools

  • They follow Javascript best practices

  • 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-28T15:58:39+00:00Added an answer on May 28, 2026 at 3:58 pm

    throw new Error("message");

    or if you want to be more specific use one of the Error Objects

    It’s important to make sure you throw real errors because they contain the stack trace. Throwing a string is stupid because it doesn’t have any meta data attached to it.

    You can also subclass errors

    // for some sensible implementation of extend 
    // https://gist.github.com/1441105#file_1pd.js
    var MyError = extend(Object.create(Error.prototype), {
       ...
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

somehow couldn't find this with a google search, but I feel like it has
First look at this url: https://stackoverflow.com/questions/tagged/xoxoxo/ This directory does not exists but somehow stackoverflow
Is it possible to somehow do this without taking out the @? It does
This somehow simple task is not so simple. I can get the number of
This is somehow subjective depending on the target translation language, but bear with me
I thought I has this nth-child or nth-of-type stuff down, but somehow it does
I need to generate multiple random values under SQL Server 2005 and somehow this
This is somehow related to my question Why is ''>0 True in Python? In
This is something I know can be done somehow , because I've done it
is this good code? can it be simplified somehow? SELECT u.id,u.title,u.title,u.first,u.last FROM (((tblusers u

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.