It seems when I use the getLine() method of the Exception class, it returns
the line number of the "throw new Exception" statement and not the line
number where the error actually occured in the source file. Am I doing
something wrong?
- Seamus 4 2796
Seamus M wrote: It seems when I use the getLine() method of the Exception class, it returns the line number of the "throw new Exception" statement and not the line number where the error actually occured in the source file. Am I doing something wrong?
- Seamus
How is the exception supposed to know where the error occurred? It
could have been anything - bad return code, incorrect data, whatever.
But in all cases, it's something you had to detect. This might have
been many lines of code before you actually threw the exception, or even
in a different (included) file.
All the exception can tell is where you threw it.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
It appears the exception should be thrown on the line immediately after the
potenially error causing code for "getLine()" to be any use. I was
anticipating it to work like the built-in errors which tell you what line of
code caused the error.
Thanks for your input.
- Seamus
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
news:ov******** ************@co mcast.com... Seamus M wrote: It seems when I use the getLine() method of the Exception class, it returns the line number of the "throw new Exception" statement and not the line number where the error actually occured in the source file. Am I doing something wrong?
- Seamus
How is the exception supposed to know where the error occurred? It could have been anything - bad return code, incorrect data, whatever. But in all cases, it's something you had to detect. This might have been many lines of code before you actually threw the exception, or even in a different (included) file.
All the exception can tell is where you threw it.
-- =============== === Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. js*******@attgl obal.net =============== ===
Seamus M wrote: It appears the exception should be thrown on the line immediately after the potenially error causing code for "getLine()" to be any use. I was anticipating it to work like the built-in errors which tell you what line of code caused the error.
Thanks for your input.
- Seamus
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message news:ov******** ************@co mcast.com...
Seamus M wrote:
It seems when I use the getLine() method of the Exception class, it returns the line number of the "throw new Exception" statement and not the line number where the error actually occured in the source file. Am I doing something wrong?
- Seamus
How is the exception supposed to know where the error occurred? It could have been anything - bad return code, incorrect data, whatever. But in all cases, it's something you had to detect. This might have been many lines of code before you actually threw the exception, or even in a different (included) file.
All the exception can tell is where you threw it.
-- ============= ===== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. js*******@att global.net ============= =====
There's a difference here. The built-in errors know where the error
occurred, because they detected the error.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
Seamus M wrote: "Jerry Stuckle" <js*******@attg lobal.net> wrote in message news:ov******** ************@co mcast.com... Seamus M wrote: It seems when I use the getLine() method of the Exception class, it returns the line number of the "throw new Exception" statement and not the line number where the error actually occured in the source file. Am I doing something wrong?
How is the exception supposed to know where the error occurred? It could have been anything - bad return code, incorrect data, whatever. But in all cases, it's something you had to detect. This might have been many lines of code before you actually threw the exception, or even in a different (included) file.
All the exception can tell is where you threw it.
It appears the exception should be thrown on the line immediately after the potenially error causing code for "getLine()" to be any use. I was anticipating it to work like the built-in errors which tell you what line of code caused the error.
I imagine you're using exceptions something like:
....
if (Some Bad Condition)
{
throw new Exception("You fool!");
}
....
As Jerry said, the exception itself has no idea what caused the error,
and what line that corresponds to.
But getLine() will direct you to the throw... line, which should be
enough of a clue to work out where the error was!
--
Oli This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: RT Lange |
last post by:
>>> class E1(Exception): pass
>>> class E2(E1): pass
>>> i = E2('foo')
>>> raise E1(i)
Traceback (most recent call last):
File "<pyshell#5>", line 1, in ?
raise E1(i)
E1: foo
|
by: Páll Ólafsson |
last post by:
Hi
I have a problem with the Microsoft.ApplicationBlocks.ExceptionManagement? I
can't get it to work in RELEASE mode? If I run the project in debug mode
the block works fine but when I run the exe file it doesn't catch any
errors?
Does anyone know what my problem might be?
Regards
|
by: Dave |
last post by:
try
{
...
}
catch (exception e)
{
cout << e.what() << endl;
}
In the code above, e is caught by value rather than polymorphically (assume
|
by: Pierre Rouleau |
last post by:
The std::exception class defined in the Standard C++ <exception> header
specifies that the constructors could throw any exception becuase they
do not have a throw() specification.
Why is that? Is this because there could be an exception thrown when
the code creates a std::exception? I would assume that is not the case.
However, if I want to create a new exception class, derived from
std::exception (say MyException) then how can I...
|
by: guy |
last post by:
i have a method which throws an exception. the thing i dont understand is
that the only change between the two versions is a line of code AFTER the one
that
throws the exception - see code below
the only difference between the il BEFORE the line throwing the exception is
a BR.S as opposed to BR, due to the length of the branch required, which
makes sense.
anyone know what is going on?
| |
by: Nick Flandry |
last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my
development environment (Win2K server running IIS 5) and a test environment (also Win2K server
running IIS 5), but fails on IIS 6 running on a Win2003 server.
The web uses Pages derived from a custom class I wrote (which itself derives from Page) to provide
some common functionality. The Page_Load handler the failing webpage starts out like this:
...
|
by: |
last post by:
I would appreciate some help in understanding the simple C# example relating
to handling exceptions. This one relates to catching an error thrown by
dividing number by zero.
There are a few things I don't understand which I hope you can help me with:
'using System;
|
by: Vadivel Kumar |
last post by:
I've a problem in handling a custom exception
The following is my custom exception class:
public class AppException : public Exception
{
public AppException (string message, Exception innerException)
{ }
public override string Message
|
by: Jarod_24 |
last post by:
Throw new Excption ("bla, bla, bla")
....
Catch E as Exception
If E.Message.Equals("bla, bla, bla") Then ...
Mostly i just use the standard "Exception"-object whenever i throw an
exception, but it would be nice sometimes to make you own
"MyException"-object that you
can then easier Catch. using:
|
by: metsys |
last post by:
We have an ASP.NET 2.0 (C#) application that is divided into multiple
layers. The multiple layers come from having a web project and 2 different
class library projects in the same solution.
I'm having difficulties figuring out the best way to handle (catch)
exceptions in the different layers and then propagating those errors back up
through the call stack to ultimately display something to the end-user.
Note this is an intranet...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |