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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:03:35+00:00 2026-06-08T22:03:35+00:00

Possible Duplicate: How to print message from caught exception? Apologies if this is basic

  • 0

Possible Duplicate:
How to print message from caught exception?

Apologies if this is basic or duplicated – I did several searches first but didn’t find anything that answered this.

If I do something basic like:

throw exception("This thing didn't work");

Where can I see that? The string doesn’t show up in the output console, stack trace, or any of the .log files associated with the project. Makes me wonder why I’m even putting a string there if it can’t be seen anywhere. I can of course use the stack trace to see where it blew up, but that kind of defeats the purpose of having exceptions in the first place.

In Java, when I give it a string, I’ll see that string in the output somewhere. I just wonder if it’s possible to reproduce this behavior in C++.

  • 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-08T22:03:38+00:00Added an answer on June 8, 2026 at 10:03 pm

    You must catch the exception in order to see the string.
    It can be useful to have an exception handler of last resort as follows:

    int main(int argc, char **argv)
    {
        try {
            ...
        }
        catch(const std::exception& e) {
            std::cout << "Uncaught exception: " << e.what() << std::endl;
        }
    }
    

    In a GUI application you can have a catch statement in the main event loop, and display the error message in a message box.

    In an event-driven non-GUI application you can also have a catch statement in the main event loop, and write the error message to a log file.

    These methods will make sure that you see all exceptions. Of course, most exceptions should be caught before they reach your exception handler of last resort.

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

Sidebar

Related Questions

Possible Duplicate: TSQL How do you output PRINT in a user defined function? This
Possible Duplicate: Why does cout print char arrays differently from other arrays? If I
Possible Duplicate: Is there a printf converter to print in binary format? Consider this
Possible Duplicate: Output (echo/print) everything from a PHP Array I have done a query
Possible Duplicate: Java exception handling In Java, is it possible to print in console
Possible Duplicate: How to print out the method name and line number and conditionally
Possible Duplicate: Why do I see strange values when I print uninitialized variables? Fun
Possible Duplicate: Print an XML document without the XML header line at the top
Possible Duplicate: Correct format specifier to print pointer (address)? When printing a pointer using
Possible Duplicate: Comparing Two Arrays Using Perl How can I print values which exist

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.