err.raise inside catch?  
Author Message
dboz555





PostPosted: Thu Sep 11 13:37:25 CDT 2003 Top

Net Framework >> err.raise inside catch? I would like to use err.raise(x) within a catch block to send an exception
back to the calling function or cain of functions. Is this ok to do? I know
if i dont use try catch fail in the child function that it will send an
exception to the calling function but i want to have error handling in all
chain functions.

any MSDN documentation on this?

DotNet319  
 
 
William





PostPosted: Thu Sep 11 13:37:25 CDT 2003 Top

Net Framework >> err.raise inside catch? I wouldn't mix unstructured and structured handlers in my code. Exceptions
and Error aren't the same class.

If you trap an exception, you can throw it again. In your scenario, you
could define a CustomException called MyException

Trap a specific exception in your routines, but only respond to MyException
at the top level handler. Everything else, make sure you don't trap
MyException.

The "I want to have error handling in all chain functions" is something you
might want to re-consider. If you aren't handling specific things and
responding to them specifically, I think you can get yourself in trouble.
There are many functions where nothing other than broad
OutofMemoryExceptions could occur. Unless you are targeting exceptions very
specifically, I'm not sure having handlers in every method is getting you
anything.

You can always use the Diagnostics.StackTrace to find out what happened...

Unless your code is that targeted for exceptions, I'd probably revisit my
original premise.'


Let me know if you have any questions.

Cheers,

Bill
"Coder" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> I would like to use err.raise(x) within a catch block to send an exception
> back to the calling function or cain of functions. Is this ok to do? I
know
> if i dont use try catch fail in the child function that it will send an
> exception to the calling function but i want to have error handling in all
> chain functions.
>
> any MSDN documentation on this?
>
>


 
 
John





PostPosted: Thu Sep 11 16:53:19 CDT 2003 Top

Net Framework >> err.raise inside catch? "Coder" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> I would like to use err.raise(x) within a catch block to send an exception
> back to the calling function or cain of functions. Is this ok to do? I
know
> if i dont use try catch fail in the child function that it will send an
> exception to the calling function but i want to have error handling in all
> chain functions.

Don't use Err.Raise or Err.<anything>, for that matter. Ever.

> any MSDN documentation on this?

You may find this helpful:

Handling and Throwing Exceptions
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/ht
ml/cpconbestpracticesforhandlingexceptions.asp)
--
John Saunders
Internet Engineer
EMail@HideDomain.com



 
 
William





PostPosted: Thu Sep 11 18:36:25 CDT 2003 Top

Net Framework >> err.raise inside catch? I second that!
"John Saunders" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> "Coder" <EMail@HideDomain.com> wrote in message
> news:EMail@HideDomain.com...
> > I would like to use err.raise(x) within a catch block to send an
exception
> > back to the calling function or cain of functions. Is this ok to do? I
> know
> > if i dont use try catch fail in the child function that it will send an
> > exception to the calling function but i want to have error handling in
all
> > chain functions.
>
> Don't use Err.Raise or Err.<anything>, for that matter. Ever.
>
> > any MSDN documentation on this?
>
> You may find this helpful:
>
> Handling and Throwing Exceptions
>
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/ht
> ml/cpconbestpracticesforhandlingexceptions.asp)
> --
> John Saunders
> Internet Engineer
> EMail@HideDomain.com
>
>
>


 
 
Scott





PostPosted: Fri Sep 12 21:00:34 CDT 2003 Top

Net Framework >> err.raise inside catch? 3rd!

"William Ryan" <EMail@HideDomain.com> wrote in message
news:%EMail@HideDomain.com...
> I second that!
> "John Saunders" <EMail@HideDomain.com> wrote in message
> news:EMail@HideDomain.com...
> > "Coder" <EMail@HideDomain.com> wrote in message
> > news:EMail@HideDomain.com...
> > > I would like to use err.raise(x) within a catch block to send an
> exception
> > > back to the calling function or cain of functions. Is this ok to do? I
> > know
> > > if i dont use try catch fail in the child function that it will send
an
> > > exception to the calling function but i want to have error handling in
> all
> > > chain functions.
> >
> > Don't use Err.Raise or Err.<anything>, for that matter. Ever.
> >
> > > any MSDN documentation on this?
> >
> > You may find this helpful:
> >
> > Handling and Throwing Exceptions
> >
>
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/ht
> > ml/cpconbestpracticesforhandlingexceptions.asp)
> > --
> > John Saunders
> > Internet Engineer
> > EMail@HideDomain.com
> >
> >
> >
>
>