- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Customizing termination behavior for uncaught exception In C++
In this tutorial, we will be discussing a program to customize behavior for an uncaught exceptions in C++.
Usually, the exception is handled by the try-catch block, but there are instances where there isn’t a matching catch block and the program just terminates. This terminate() function is modifiable as per user requirements.
Example
#include <exception> #include <iostream> using namespace std; //defining custom terminator void myhandler(){ cout << "Inside new terminate handler\n"; abort(); } int main(){ set_terminate(myhandler); try { cout << "Inside try block\n"; throw 100; } catch (char a){ cout << "Inside catch block\n"; } return 0; }
Output
Inside try block Inside new terminate handler
- Related Articles
- toDataURL throw Uncaught Security exception in HTML
- What is process termination?
- Default virtual behavior in C++ vs Java
- Customizing SAP ERP industry specific
- Customizing SAP HANA Perspective in HANA Studio
- Exception in C#
- Is segmentation fault actual undefined behavior in C++?
- Cable Modem Termination System (CMTS)
- Different options in customizing SAP HANA Studio Perspective
- Pre & post increment operator behavior in C, C++, Java, and C#
- Exception Propagation in C#
- Customizing annotation with Seaborn's FacetGrid
- Process Creation vs Process Termination in Operating System
- Delete file or directory on termination in Java
- Understanding IndexOutOfRangeException Exception in C#

Advertisements