Hi all,
The title of this post may sound a bit weird, but I was wondering about the
following nonetheless.
I have a class libray containing, say, 4 classes: A, B, C, D. Class A
somehow has a reference to B, B has a reference to C, and C to D.
If an exception happens in class D, I would like class A to get a
notification of this (all execution on classes B to D should be terminated).
I am wondering how to do this. The following seems like a bad idea:
class D {
{
try(...)
catch(SomeExcep tion ex)
throw new SomeException(" Error in D");
}
class C
{
D d = new D();
try
{ d.doSomething() ; }
catch(SomeExcep tion ex)
{ throw new SomeException(e x.Message); }
}
and catch THAT exception in B, and throw it to A. I think you get the idea
:) I'm quite sure this is a bad idea. But how should I structure it then? No
error handling at all in classes B to D is even worse. I hope someone can
give me a good idea.
Thanks!
Razzie 10 1293
Razzie,
If you want to invalidate the classes when an exception occurs, then you
will have to use the try/catch block and set a flag indicating that the
class can not be used. You would then check that flag for every operation
on that class.
I would say that this is a bit overkill, plus, you are not designing
your classes to be resilient enough in the face of these exceptions.
Also, are you throwing exceptions as a result of say, errors in logic?
If so, you might want to reconsider using exceptions (is the error in logic
truly an exceptional case) and use some sort of return value,
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Razzie" <ra****@quickne t.nl> wrote in message
news:uo******** ******@TK2MSFTN GP10.phx.gbl... Hi all,
The title of this post may sound a bit weird, but I was wondering about the following nonetheless.
I have a class libray containing, say, 4 classes: A, B, C, D. Class A somehow has a reference to B, B has a reference to C, and C to D. If an exception happens in class D, I would like class A to get a notification of this (all execution on classes B to D should be terminated). I am wondering how to do this. The following seems like a bad idea:
class D { { try(...) catch(SomeExcep tion ex) throw new SomeException(" Error in D"); }
class C { D d = new D(); try { d.doSomething() ; } catch(SomeExcep tion ex) { throw new SomeException(e x.Message); } }
and catch THAT exception in B, and throw it to A. I think you get the idea :) I'm quite sure this is a bad idea. But how should I structure it then? No error handling at all in classes B to D is even worse. I hope someone can give me a good idea.
Thanks!
Razzie
Hello Nicholas,
Some classes use so-called template files to read data from. Exceptions
could occur when a template file is missing, has invalid data, etc. That
should never happen but IF it happens, execution cannot continue.
I was really wondering if catching and rethrowing an exception is very bad
performance-wise (I guess it is, since catching costs performance) so I
don't want to go that way.
I've been thinking of returning some value myself, for example return null
instead of an object and check if an object is null ---> something must have
gone wrong. But I'd have to use THAT throughout class D to A, and I was
wondering if there was just one 'fast' way.
Isn't it possible to use events for this? If an exception in D happens, an
event is raised in A...?
Thanks,
Razzie
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:Oc******** ******@TK2MSFTN GP11.phx.gbl... Razzie,
If you want to invalidate the classes when an exception occurs, then you will have to use the try/catch block and set a flag indicating that the class can not be used. You would then check that flag for every operation on that class.
I would say that this is a bit overkill, plus, you are not designing your classes to be resilient enough in the face of these exceptions.
Also, are you throwing exceptions as a result of say, errors in logic? If so, you might want to reconsider using exceptions (is the error in logic truly an exceptional case) and use some sort of return value,
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Razzie" <ra****@quickne t.nl> wrote in message news:uo******** ******@TK2MSFTN GP10.phx.gbl... Hi all,
The title of this post may sound a bit weird, but I was wondering about the following nonetheless.
I have a class libray containing, say, 4 classes: A, B, C, D. Class A somehow has a reference to B, B has a reference to C, and C to D. If an exception happens in class D, I would like class A to get a notification of this (all execution on classes B to D should be terminated). I am wondering how to do this. The following seems like a bad idea:
class D { { try(...) catch(SomeExcep tion ex) throw new SomeException(" Error in D"); }
class C { D d = new D(); try { d.doSomething() ; } catch(SomeExcep tion ex) { throw new SomeException(e x.Message); } }
and catch THAT exception in B, and throw it to A. I think you get the idea :) I'm quite sure this is a bad idea. But how should I structure it then? No error handling at all in classes B to D is even worse. I hope someone can give me a good idea.
Thanks!
Razzie
Razzie,
You could use events, but that seems like a lot of work as well.
If D uses C and C uses B and B uses A, why not have the process that
makes calls on D just end? I mean, why not just ditch that process and then
start over, discarding the chain?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Razzie" <ra****@quickne t.nl> wrote in message
news:eG******** ******@TK2MSFTN GP15.phx.gbl... Hello Nicholas,
Some classes use so-called template files to read data from. Exceptions could occur when a template file is missing, has invalid data, etc. That should never happen but IF it happens, execution cannot continue. I was really wondering if catching and rethrowing an exception is very bad performance-wise (I guess it is, since catching costs performance) so I don't want to go that way. I've been thinking of returning some value myself, for example return null instead of an object and check if an object is null ---> something must have gone wrong. But I'd have to use THAT throughout class D to A, and I was wondering if there was just one 'fast' way. Isn't it possible to use events for this? If an exception in D happens, an event is raised in A...?
Thanks,
Razzie
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in message news:Oc******** ******@TK2MSFTN GP11.phx.gbl... Razzie,
If you want to invalidate the classes when an exception occurs, then you will have to use the try/catch block and set a flag indicating that the class can not be used. You would then check that flag for every operation on that class.
I would say that this is a bit overkill, plus, you are not designing your classes to be resilient enough in the face of these exceptions.
Also, are you throwing exceptions as a result of say, errors in logic? If so, you might want to reconsider using exceptions (is the error in logic truly an exceptional case) and use some sort of return value,
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Razzie" <ra****@quickne t.nl> wrote in message news:uo******** ******@TK2MSFTN GP10.phx.gbl... Hi all,
The title of this post may sound a bit weird, but I was wondering about the following nonetheless.
I have a class libray containing, say, 4 classes: A, B, C, D. Class A somehow has a reference to B, B has a reference to C, and C to D. If an exception happens in class D, I would like class A to get a notification of this (all execution on classes B to D should be terminated). I am wondering how to do this. The following seems like a bad idea:
class D { { try(...) catch(SomeExcep tion ex) throw new SomeException(" Error in D"); }
class C { D d = new D(); try { d.doSomething() ; } catch(SomeExcep tion ex) { throw new SomeException(e x.Message); } }
and catch THAT exception in B, and throw it to A. I think you get the idea :) I'm quite sure this is a bad idea. But how should I structure it then? No error handling at all in classes B to D is even worse. I hope someone can give me a good idea.
Thanks!
Razzie
Razzie wrote: Hi all,
The title of this post may sound a bit weird, but I was wondering about the following nonetheless.
I have a class libray containing, say, 4 classes: A, B, C, D. Class A somehow has a reference to B, B has a reference to C, and C to D. If an exception happens in class D, I would like class A to get a notification of this (all execution on classes B to D should be terminated). I am wondering how to do this. The following seems like a bad idea: class D { { try(...) catch(SomeExcep tion ex) throw new SomeException(" Error in D"); }
class C { D d = new D(); try { d.doSomething() ; } catch(SomeExcep tion ex) { throw new SomeException(e x.Message); } }
and catch THAT exception in B, and throw it to A. I think you get the idea :) I'm quite sure this is a bad idea. But how should I structure it then? No error handling at all in classes B to D is even worse. I hope someone can give me a good idea.
Thanks!
Razzie
If you call that method in D through C, B and A (that is, externally you
only work with A), then if an exception is thrown in D (or C or B)
you can catch it in A without a catch-and-rethrow in the intermediate
layers.
Hans Kesting
Hehe, because I don't know how..
Class A will be running continuously in a windows service. Depending on
certain data it will create a new instance of B, and B uses C, and C uses D.
How do I 'break' this chain when an error occurs in D? Maybe I'm looking way
too difficult at this situation, but I don't see it. The only way I can see
to tell A that something went wrong, is either rethrow every exception
through the chain and catch it in A (which I don't want) or use specific
return values? But I was hoping there would be an easy way. If there isn't,
please tell me, and I'll most likely use specific return values :)
Thanks,
Razzie
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:eQ******** ******@TK2MSFTN GP14.phx.gbl... Razzie,
You could use events, but that seems like a lot of work as well.
If D uses C and C uses B and B uses A, why not have the process that makes calls on D just end? I mean, why not just ditch that process and then start over, discarding the chain?
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Razzie" <ra****@quickne t.nl> wrote in message news:eG******** ******@TK2MSFTN GP15.phx.gbl... Hello Nicholas,
Some classes use so-called template files to read data from. Exceptions could occur when a template file is missing, has invalid data, etc. That should never happen but IF it happens, execution cannot continue. I was really wondering if catching and rethrowing an exception is very bad performance-wise (I guess it is, since catching costs performance) so I don't want to go that way. I've been thinking of returning some value myself, for example return null instead of an object and check if an object is null ---> something must have gone wrong. But I'd have to use THAT throughout class D to A, and I was wondering if there was just one 'fast' way. Isn't it possible to use events for this? If an exception in D happens, an event is raised in A...?
Thanks,
Razzie
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in message news:Oc******** ******@TK2MSFTN GP11.phx.gbl... Razzie,
If you want to invalidate the classes when an exception occurs, then you will have to use the try/catch block and set a flag indicating that the class can not be used. You would then check that flag for every operation on that class.
I would say that this is a bit overkill, plus, you are not designing your classes to be resilient enough in the face of these exceptions.
Also, are you throwing exceptions as a result of say, errors in logic? If so, you might want to reconsider using exceptions (is the error in logic truly an exceptional case) and use some sort of return value,
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Razzie" <ra****@quickne t.nl> wrote in message news:uo******** ******@TK2MSFTN GP10.phx.gbl... Hi all,
The title of this post may sound a bit weird, but I was wondering about the following nonetheless.
I have a class libray containing, say, 4 classes: A, B, C, D. Class A somehow has a reference to B, B has a reference to C, and C to D. If an exception happens in class D, I would like class A to get a notification of this (all execution on classes B to D should be terminated). I am wondering how to do this. The following seems like a bad idea:
class D { { try(...) catch(SomeExcep tion ex) throw new SomeException(" Error in D"); }
class C { D d = new D(); try { d.doSomething() ; } catch(SomeExcep tion ex) { throw new SomeException(e x.Message); } }
and catch THAT exception in B, and throw it to A. I think you get the idea :) I'm quite sure this is a bad idea. But how should I structure it then? No error handling at all in classes B to D is even worse. I hope someone can give me a good idea.
Thanks!
Razzie
Hmm I guess I could do that... my first thought was that would be a little
bit 'dirty' to do, but when I think of it, I guess it's not that bad...
unless anyone thinks otherwise. thanks.
"Hans Kesting" <ne***********@ spamgourmet.com > wrote in message
news:u$******** ******@TK2MSFTN GP10.phx.gbl... Razzie wrote: Hi all,
The title of this post may sound a bit weird, but I was wondering about the following nonetheless.
I have a class libray containing, say, 4 classes: A, B, C, D. Class A somehow has a reference to B, B has a reference to C, and C to D. If an exception happens in class D, I would like class A to get a notification of this (all execution on classes B to D should be terminated). I am wondering how to do this. The following seems like a bad idea: class D { { try(...) catch(SomeExcep tion ex) throw new SomeException(" Error in D"); }
class C { D d = new D(); try { d.doSomething() ; } catch(SomeExcep tion ex) { throw new SomeException(e x.Message); } }
and catch THAT exception in B, and throw it to A. I think you get the idea :) I'm quite sure this is a bad idea. But how should I structure it then? No error handling at all in classes B to D is even worse. I hope someone can give me a good idea.
Thanks!
Razzie
If you call that method in D through C, B and A (that is, externally you only work with A), then if an exception is thrown in D (or C or B) you can catch it in A without a catch-and-rethrow in the intermediate layers.
Hans Kesting
Razzie,
Ok, if you are in a service, then you don't have just one method that is
running continuously, right? Rather, you have some sort of event (time, a
message coming in, etc, etc) which then triggers code to be run. At that
point, you should create A, and then the rest of the chain.
Then, wrap the whole event handler in a try/catch block, and don't
bother catching events in the other classes. If an exception occurs, log it
somewhere. You shouldn't have to worry otherwise, since you will create a
new instance of A each time the event occurs.
Also, I would say if you are doing something strictly on a schedule, to
not use a service, as you are just wasting processing cycles waiting.
Rather, use a scheduled task in windows, and create your application as an
EXE that is run at certain times.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Razzie" <ra****@quickne t.nl> wrote in message
news:%2******** *******@TK2MSFT NGP12.phx.gbl.. . Hehe, because I don't know how..
Class A will be running continuously in a windows service. Depending on certain data it will create a new instance of B, and B uses C, and C uses D. How do I 'break' this chain when an error occurs in D? Maybe I'm looking way too difficult at this situation, but I don't see it. The only way I can see to tell A that something went wrong, is either rethrow every exception through the chain and catch it in A (which I don't want) or use specific return values? But I was hoping there would be an easy way. If there isn't, please tell me, and I'll most likely use specific return values :)
Thanks,
Razzie
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in message news:eQ******** ******@TK2MSFTN GP14.phx.gbl... Razzie,
You could use events, but that seems like a lot of work as well.
If D uses C and C uses B and B uses A, why not have the process that makes calls on D just end? I mean, why not just ditch that process and then start over, discarding the chain?
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Razzie" <ra****@quickne t.nl> wrote in message news:eG******** ******@TK2MSFTN GP15.phx.gbl... Hello Nicholas,
Some classes use so-called template files to read data from. Exceptions could occur when a template file is missing, has invalid data, etc. That should never happen but IF it happens, execution cannot continue. I was really wondering if catching and rethrowing an exception is very bad performance-wise (I guess it is, since catching costs performance) so I don't want to go that way. I've been thinking of returning some value myself, for example return null instead of an object and check if an object is null ---> something must have gone wrong. But I'd have to use THAT throughout class D to A, and I was wondering if there was just one 'fast' way. Isn't it possible to use events for this? If an exception in D happens, an event is raised in A...?
Thanks,
Razzie
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in message news:Oc******** ******@TK2MSFTN GP11.phx.gbl... Razzie,
If you want to invalidate the classes when an exception occurs, then you will have to use the try/catch block and set a flag indicating that the class can not be used. You would then check that flag for every operation on that class.
I would say that this is a bit overkill, plus, you are not designing your classes to be resilient enough in the face of these exceptions.
Also, are you throwing exceptions as a result of say, errors in logic? If so, you might want to reconsider using exceptions (is the error in logic truly an exceptional case) and use some sort of return value,
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Razzie" <ra****@quickne t.nl> wrote in message news:uo******** ******@TK2MSFTN GP10.phx.gbl... > Hi all, > > The title of this post may sound a bit weird, but I was wondering > about the following nonetheless. > > I have a class libray containing, say, 4 classes: A, B, C, D. Class A > somehow has a reference to B, B has a reference to C, and C to D. > If an exception happens in class D, I would like class A to get a > notification of this (all execution on classes B to D should be > terminated). I am wondering how to do this. The following seems like a > bad idea: > > class D { > { > try(...) > catch(SomeExcep tion ex) > throw new SomeException(" Error in D"); > } > > class C > { > D d = new D(); > try > { d.doSomething() ; } > catch(SomeExcep tion ex) > { throw new SomeException(e x.Message); } > } > > and catch THAT exception in B, and throw it to A. I think you get the > idea :) I'm quite sure this is a bad idea. But how should I structure > it then? No error handling at all in classes B to D is even worse. I > hope someone can give me a good idea. > > Thanks! > > Razzie >
Allright thanks for the excellent help Nicholas. And thank you too Hans
Kesting.
As for the service - yeah data is coming in, but at very random intervals :)
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:et******** ******@TK2MSFTN GP09.phx.gbl... Razzie,
Ok, if you are in a service, then you don't have just one method that is running continuously, right? Rather, you have some sort of event (time, a message coming in, etc, etc) which then triggers code to be run. At that point, you should create A, and then the rest of the chain.
Then, wrap the whole event handler in a try/catch block, and don't bother catching events in the other classes. If an exception occurs, log it somewhere. You shouldn't have to worry otherwise, since you will create a new instance of A each time the event occurs.
Also, I would say if you are doing something strictly on a schedule, to not use a service, as you are just wasting processing cycles waiting. Rather, use a scheduled task in windows, and create your application as an EXE that is run at certain times.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Razzie" <ra****@quickne t.nl> wrote in message news:%2******** *******@TK2MSFT NGP12.phx.gbl.. . Hehe, because I don't know how..
Class A will be running continuously in a windows service. Depending on certain data it will create a new instance of B, and B uses C, and C uses D. How do I 'break' this chain when an error occurs in D? Maybe I'm looking way too difficult at this situation, but I don't see it. The only way I can see to tell A that something went wrong, is either rethrow every exception through the chain and catch it in A (which I don't want) or use specific return values? But I was hoping there would be an easy way. If there isn't, please tell me, and I'll most likely use specific return values :)
Thanks,
Razzie
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in message news:eQ******** ******@TK2MSFTN GP14.phx.gbl... Razzie,
You could use events, but that seems like a lot of work as well.
If D uses C and C uses B and B uses A, why not have the process that makes calls on D just end? I mean, why not just ditch that process and then start over, discarding the chain?
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Razzie" <ra****@quickne t.nl> wrote in message news:eG******** ******@TK2MSFTN GP15.phx.gbl... Hello Nicholas,
Some classes use so-called template files to read data from. Exceptions could occur when a template file is missing, has invalid data, etc. That should never happen but IF it happens, execution cannot continue. I was really wondering if catching and rethrowing an exception is very bad performance-wise (I guess it is, since catching costs performance) so I don't want to go that way. I've been thinking of returning some value myself, for example return null instead of an object and check if an object is null ---> something must have gone wrong. But I'd have to use THAT throughout class D to A, and I was wondering if there was just one 'fast' way. Isn't it possible to use events for this? If an exception in D happens, an event is raised in A...?
Thanks,
Razzie
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in message news:Oc******** ******@TK2MSFTN GP11.phx.gbl... > Razzie, > > If you want to invalidate the classes when an exception occurs, > then you will have to use the try/catch block and set a flag > indicating that the class can not be used. You would then check that > flag for every operation on that class. > > I would say that this is a bit overkill, plus, you are not > designing your classes to be resilient enough in the face of these > exceptions. > > Also, are you throwing exceptions as a result of say, errors in > logic? If so, you might want to reconsider using exceptions (is the > error in logic truly an exceptional case) and use some sort of return > value, > > Hope this helps. > > > -- > - Nicholas Paldino [.NET/C# MVP] > - mv*@spam.guard. caspershouse.co m > > "Razzie" <ra****@quickne t.nl> wrote in message > news:uo******** ******@TK2MSFTN GP10.phx.gbl... >> Hi all, >> >> The title of this post may sound a bit weird, but I was wondering >> about the following nonetheless. >> >> I have a class libray containing, say, 4 classes: A, B, C, D. Class A >> somehow has a reference to B, B has a reference to C, and C to D. >> If an exception happens in class D, I would like class A to get a >> notification of this (all execution on classes B to D should be >> terminated). I am wondering how to do this. The following seems like >> a bad idea: >> >> class D { >> { >> try(...) >> catch(SomeExcep tion ex) >> throw new SomeException(" Error in D"); >> } >> >> class C >> { >> D d = new D(); >> try >> { d.doSomething() ; } >> catch(SomeExcep tion ex) >> { throw new SomeException(e x.Message); } >> } >> >> and catch THAT exception in B, and throw it to A. I think you get the >> idea :) I'm quite sure this is a bad idea. But how should I structure >> it then? No error handling at all in classes B to D is even worse. I >> hope someone can give me a good idea. >> >> Thanks! >> >> Razzie >> > >
Use a return value of bool for every function to indicate success or
failure, then just propogate this up. You can use out or ref parameters for
the actual return values. I've used this to much success - if the function
fails, it simply puts null in the out parameter, but the return value
naturally lends itself to an if statement which separates what happens in an
error to what happens if successful, in the front end code - so you're not
going to mind that it's null because if it is, you'll be in the code block
that writes "There was an error". Don't make the mistake of putting 'return
true' in the finally though - put it at the end of the try.
e.g.
class D
{
static bool DoTheActualWork (out string retval)
{
try
{
...do the work, that assigns to retval
return true;
}
catch(Exception ex) {retval = null; return false;}
}
}
class C { static bool GetRawData(out string retval) {return
D.DoTheActualWo rk(out retval); }
class B { static bool GetData(out string retval) {return C.GetRawData(ou t
retval); }
class A
{
static void Main()
{
string thedata;
if(B.GetData(ou t thedata)) Console.WriteLi ne("The data is {0}",
thedata);
else Console.WriteLi ne("There was an error!");
}
}
Another cunning use of finally blocks is when you aren't necessarily worried
about an exception, but want to return from a function the return value of a
method call on an object, but that object needs cleaning up. You then don't
need to assign a variable.
e.g.
objectdata getdata(someobj ect theobj)
{
try{return theobj.getheobj ectdatathatwont fail();}
finally{theobj. cleanitup();}
}
"Razzie" <ra****@quickne t.nl> wrote in message
news:uo******** ******@TK2MSFTN GP10.phx.gbl... Hi all,
The title of this post may sound a bit weird, but I was wondering about the following nonetheless.
I have a class libray containing, say, 4 classes: A, B, C, D. Class A somehow has a reference to B, B has a reference to C, and C to D. If an exception happens in class D, I would like class A to get a notification of this (all execution on classes B to D should be terminated). I am wondering how to do this. The following seems like a bad idea:
class D { { try(...) catch(SomeExcep tion ex) throw new SomeException(" Error in D"); }
class C { D d = new D(); try { d.doSomething() ; } catch(SomeExcep tion ex) { throw new SomeException(e x.Message); } }
and catch THAT exception in B, and throw it to A. I think you get the idea :) I'm quite sure this is a bad idea. But how should I structure it then? No error handling at all in classes B to D is even worse. I hope someone can give me a good idea.
Thanks!
Razzie This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: OvErboRed |
last post by:
I just read a whole bunch of threads on microsoft.public.dotnet.* regarding
checked exceptions (the longest-running of which seems to be <cJQQ9.4419
$j94.834878@news02.tsnz.net>.
My personal belief is that checked exceptions should be required in .NET. I
find that many others share the same views as I do. It is extremely
frustrating to have to work around this with hacks like Abstract ADO.NET
and CLRxLint (which still don't solve the...
|
by: Noah Roberts |
last post by:
I am a bit confused about how inheritance works with regard to
exceptions apparently.
class ParentEx : public std::exception
{
};
class SubEx : public ParentEx,std::runtime_error
{
};
|
by: Turamnvia Suouriviaskimatta |
last post by:
I 'm following various posting in "comp.lang.ada, comp.lang.c++ ,
comp.realtime, comp.software-eng" groups regarding selection of a
programming language of C, C++ or Ada for safety critical real-time
applications. The majority of expert/people recommend Ada for safety
critical real-time applications. I've many years of experience in C/C++ (and
Delphi) but no Ada knowledge.
May I ask if it is too difficult to move from C/C++ to Ada?...
|
by: Ramza Brown |
last post by:
This mysql_error doesnt give me an error below, but when I run it at the
global scope it does give me errors. I went ahead and checked for
mysql_error(), but normally I dont have to, why?
public function runQuery() {
try {
/// Use mysql_error() to check for errors
if (!empty($this->build_query)) {
$this->sql_result = mysql_query($this->build_query);
|
by: cat |
last post by:
I had a long and heated discussion with other developers on my team on when
it makes sense to throw an exception and when to use an alternate solution.
The .NET documentation recommends that an exception should be thrown only in
exceptional situations. It turned out that each of my colleagues had their
own interpretation about what an "exceptional situation" may actually be.
First of all, myself I’m against using exceptions extensively,...
| |
by: Steve |
last post by:
I have read a couple articles online, read my Jesse Liberty book but I am
still confused as to just what the best practices are for using exceptions.
I keep changing how I'm working with them and it has now, after 15k lines of
code resulted in a royal mess!
It's my hope to ask some specific questions with scenario examples and that
some of you might offer a little guidance or general suggestions.
1) string...
|
by: Zytan |
last post by:
I know that WebRequest.GetResponse can throw WebException from
internet tutorials. However in the MSDN docs:
http://msdn2.microsoft.com/en-us/library/system.net.webrequest.getresponse.aspx
It only lists NotImplementedException in the Exceptions section.
(Note that it does mention WebException in the Remarks section, but
who knows if this is always the case for such classes, and thus
perhaps they can't be trusted to always list these, and...
|
by: RedSon |
last post by:
Chapter 3: What are the most common Exceptions and what do they mean?
As we saw in the last chapter, there isn't only the standard Exception, but you also get special exceptions like NullPointerException or ArrayIndexOutOfBoundsException. All of these extend the basic class Exception.
In general, you can sort Exceptions into two groups: Checked and unchecked Exceptions. Checked Exceptions are checked by the compiler at compilation time. Most...
|
by: Slaunger |
last post by:
Hi there,
I am a newcomer to Pyhton coming from Java working on a relatively
large Pyhton project with several packages and modules. To improve
exception handling I would like to introduce some user-defined
exceptions to distinguish between exceptions raised in self-written
code as compared to std libray modules used there-in.
Say, for instance I would like to define a MyParseError exception to
indicate that something has gone wrong...
|
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: 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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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...
| |