Error handling from SP that call SP`s

  • Hey all,

    I have a stored procedure that calls many other stored procs - some of which in turn call other stored procs.

    I have built a try catch error handle that if an error occurs it logs the issue (rather then just dying like it used to).

    All is running well.

    Now however i want to put in a new proc - that will probably be called by lots of the stored procedures in this main proc (hope your following my thoughts here!).

    BUT...... here is my question.

    If this stored proc errors i do not want the main package to error. If i use the try catch in this sub\sub procedure - does that mean that the main error handle wont fire? and the main proc will just continue on its course.

    If so thats exactly what i want to do. If someone can give me an idea of how this works it would be great - i have tried to find details on how levels of error handling work, but i cant seem to find much. Probably wrong search terms.

    Thanks in advance.

    Dan

  • Do not re-raise the error in your CATCH block, then calling stored proc will have no idea about any error happened in the called proc.

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • Thats great. Thank you!

    I presume i would be equally ok by raising the error but with a severity under 10?

    Dan

  • Yes, you are right.

    Raising error with severity less than 10 is the mechanism to return messages back to the caller. If called from within TRY block they will not transfer control to CATCH one.

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply