473,396 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Programable exception handling.

Hi,
i m unable to make a programable exception handling.
i can just throw an exception and catch it and try for ones.
but its not enough, i want to an exception which can work untill user
dont put valid statements or condition.
and i want to learn more about it.

--
muzammil peer
Aug 23 '08 #1
7 1405
Muzammil wrote:
i m unable to make a programable exception handling.
What exactly do you mean by this?
i can just throw an exception and catch it and try for ones.
Well, that's how exceptions work, don't they?
but its not enough, i want to an exception which can work untill user
dont put valid statements or condition.
You aren't really supposed to use exceptions for that. Wrong user input
is not an exceptional case.
--
Christian Hackl
Aug 23 '08 #2
On Aug 23, 10:05 am, Christian Hackl <ha...@sbox.tugraz.atwrote:
Muzammil wrote:
i m unable to make a programable exception handling.

What exactly do you mean by this?
i can just throw an exception and catch it and try for ones.

Well, that's how exceptions work, don't they?
but its not enough, i want to an exception which can work untill user
dont put valid statements or condition.

You aren't really supposed to use exceptions for that. Wrong user input
is not an exceptional case.

--
Christian Hackl
i want the exception handling like we do in visual c#.
in which we dont exit(terminate on catching in c++) from program.
Aug 24 '08 #3
On Sun, 24 Aug 2008 07:26:05 -0700, Muzammil wrote:
On Aug 23, 10:05 am, Christian Hackl <ha...@sbox.tugraz.atwrote:
>Muzammil wrote:
i m unable to make a programable exception handling.

What exactly do you mean by this?
i can just throw an exception and catch it and try for ones.

Well, that's how exceptions work, don't they?
but its not enough, i want to an exception which can work untill user
dont put valid statements or condition.

You aren't really supposed to use exceptions for that. Wrong user input
is not an exceptional case.

i want the exception handling like we do in visual c#. in which we dont
exit(terminate on catching in c++) from program.
Why do you think you need to exit when you catch an exception?

--
OU
Aug 24 '08 #4
Muzammil wrote:
i want the exception handling like we do in visual c#.
in which we dont exit(terminate on catching in c++) from program.
Granted, I don't know much about C#, but from I gather from checking the
very first Google hit for "c# exception handling" [1], I don't see how
C# is any different with regard to uncaught exceptions:

| If a user (programmer) do not provide a mechanism to handle these
| anomalies, the .NET run time environment provide a default mechanism,
| which terminates the program execution.
So it is still not clear what you mean.

#include <stdexcept>
#include <iostream>

void f()
{
throw std::runtime_error("...");
}

void g()
{
try
{
f();
}
catch (std::runtime_error const &)
{
std::cout << "program does *not* terminate\n";
}

// ...
}
[1]
http://www.c-sharpcorner.com/UploadF...ginCSharp.aspx

--
Christian Hackl
Aug 24 '08 #5
i want that if i found an error mean exception is thrown.
when we catch this exception then the next step is of try.
but this try action is taken one time not many times when error is
thrown. and program is terminated.
i dont want this.that my program going to terminate.

Christian Hackl wrote:
Muzammil wrote:
i want the exception handling like we do in visual c#.
in which we dont exit(terminate on catching in c++) from program.

Granted, I don't know much about C#, but from I gather from checking the
very first Google hit for "c# exception handling" [1], I don't see how
C# is any different with regard to uncaught exceptions:

| If a user (programmer) do not provide a mechanism to handle these
| anomalies, the .NET run time environment provide a default mechanism,
| which terminates the program execution.
So it is still not clear what you mean.

#include <stdexcept>
#include <iostream>

void f()
{
throw std::runtime_error("...");
}

void g()
{
try
{
f();
}
catch (std::runtime_error const &)
{
std::cout << "program does *not* terminate\n";
}

// ...
}
[1]
http://www.c-sharpcorner.com/UploadF...ginCSharp.aspx

--
Christian Hackl
Aug 25 '08 #6
"Muzammil" <mu*************@gmail.comwrote in message news:2e**********************************@2g2000hs n.googlegroups.com...
>i want that if i found an error mean exception is thrown.
when we catch this exception then the next step is of try.
but this try action is taken one time not many times when error is
thrown. and program is terminated.
That is not true. Each time the exception is thrown at that place it will
be caught at the same try. Can you give an example of what you mean that
the try action is taken only once?
i dont want this.that my program going to terminate.
It only terminates if the exception is not caught.
If you do not catch an exception, the program has no choice but to terminate,
what else do you want to happen?
(Of course, you may override the global terminate() function,
but that has a lot of pitfalls and even then there is no way to continue the
program normally.)

Christian Hackl wrote:
>Muzammil wrote:
i want the exception handling like we do in visual c#.
in which we dont exit(terminate on catching in c++) from program.

Granted, I don't know much about C#, but from I gather from checking the
very first Google hit for "c# exception handling" [1], I don't see how
C# is any different with regard to uncaught exceptions:

| If a user (programmer) do not provide a mechanism to handle these
| anomalies, the .NET run time environment provide a default mechanism,
| which terminates the program execution.
So it is still not clear what you mean.

#include <stdexcept>
#include <iostream>

void f()
{
throw std::runtime_error("...");
}

void g()
{
try
{
f();
}
catch (std::runtime_error const &)
{
std::cout << "program does *not* terminate\n";
}

// ...
}
[1]
http://www.c-sharpcorner.com/UploadF...ginCSharp.aspx

--
Christian Hackl
Aug 25 '08 #7
On Mon, 25 Aug 2008 00:43:13 -0700, Muzammil wrote:
i want that if i found an error mean exception is thrown. when we
catch this exception then the next step is of try. but this try
action is taken one time not many times when error is thrown. and
program is terminated.
i dont want this.that my program going to terminate.
Why don't you post some code showing what you claim is not working?

#include <iostream>

int main() {
while(true) {
try {
throw "exception";
}
catch(char const * e) {
std::cout<<e<<std::endl;
}
}
return 0;
}

--
OU

Aug 25 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: adi | last post by:
Dear all, This is more like a theoretical or conceptual question: which is better, using exception or return code for a .NET component? I had created a COM object (using VB6), which uses...
7
by: Noor | last post by:
please tell the technique of centralize exception handling without try catch blocks in c#.
3
by: Master of C++ | last post by:
Hi, I am an absolute newbie to Exception Handling, and I am trying to retrofit exception handling to a LOT of C++ code that I've written earlier. I am just looking for a bare-bones, low-tech...
2
by: tom | last post by:
Hi, I am developing a WinForm application and I am looking for a guide on where to place Exception Handling. My application is designed into three tiers UI, Business Objects, and Data Access...
9
by: C# Learner | last post by:
Some time ago, I remember reading a discussion about the strengths and weaknesses of exception handling. One of the weaknesses that was put forward was that exception handling is inefficient (in...
44
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
4
by: Ele | last post by:
When Exception handling disabled compiler still spits out "C++ exception handler used." Why is that? Why does it ask for "Specify /EHsc"? Thanks! c:\Program Files\Microsoft Visual Studio...
41
by: Zytan | last post by:
Ok something simple like int.Parse(string) can throw these exceptions: ArgumentNullException, FormatException, OverflowException I don't want my program to just crash on an exception, so I must...
1
by: George2 | last post by:
Hello everyone, Such code segment is used to check whether function call or exception- handling mechanism runs out of memory first (written by Bjarne), void perverted() { try{
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.