.. do stuff
..message about bad sign.
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
I'm not sure of the correlation here between the example you gave and the
example I gave,
but yes, had I chosen that particular style of signaling an error, I would
use the
exception type so I could issue a meaningful error message. Otherwise,
the exceptions
would all end up reporting "Syntax error", which is not exactly
construable as a
user-friendly interface.
joe
On Wed, 30 May 2007 22:56:18 -0700, "Ashot Geodakov"
<a_geodakov@nospam.hotmail.com>
wrote:
I remember someone I worked with in the past, who loved to create a class
for each small task.
Instead of just
int a = 2 + 2;
he wrote:
class Sum
{
private:
int result;
public:
Sum( int a, int b ) : result( 0 ) { result = a + b; }
GetResult() { return result; }
};
So, SBadSignException, huh? Is it for the situation when the first
character
in the string is not a digit or "+" or "-"?
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
news:9gds53t23d6j8mhf1aei6ftnp1h09b0nro@4ax.com...
Whenever I want to throw exceptions to represent problems, I always
create
an abstract
superclass exception, e.g., CLexicalException, then I can derive
subclasses such as
CBadSignException, CIllegalDigitException, and so on. So the caller
knows
that any
exception thrown is always a member of the superclass, and could create
a
superclass catch
clause to capture the exception.
joe
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm