How to find out what is causing an exception

Greg Wilson-Lindberg 126 Reputation points
2022-12-08T22:12:09.787+00:00

I've got a program that I am running with the VS debugger, and I am getting a number of exceptions like this:
Exception thrown at 0x00007FF8D5E7CD29 in RfidWinTest.exe: Microsoft C++ exception: unsigned long at memory location 0x0000009914CFDFE8.

How do I find out what is causing these? The debugger isn't stopping on my code. Some of them are followed by a thread closing.

Regards, Greg

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,630 questions
{count} vote

Accepted answer
  1. RLWA32 43,051 Reputation points
    2022-12-09T17:52:51.96+00:00

    The Visual Studio debugger allows you to configure it to break when exceptions are thrown. The settings are found in the Debug->Windows->Exception Settings window. For example,

    268976-exceptionsettings.png

    I don't know if this will help in your particular situation. In the posted image I checked the "All C++ Exeptions Not in this list" box so that the debugger would break if an unsigned long was thrown.

    You can test the settings -

       // CppException.cpp : This file contains the 'main' function. Program execution begins and ends there.  
       //  
         
       #include <iostream>  
       #include <stdexcept>  
         
         
       int main()  
       {  
           try  
           {  
               throw std::exception("C++ exception");  
           }  
           catch (const std::exception& ex)  
           {  
               std::cout << "Caught exception " << ex.what() << std::endl;  
           }  
         
           try  
           {  
               throw (unsigned long)42;  
           }  
           catch (unsigned long ul)  
           {  
               std::cout << "Caught exception " << ul << std::endl;  
           }  
         
           return 0;  
       }  
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful