Home All Groups Group Topic Archive Search About

how to override/trap Tsql errmsg and use custom errmsg in SP?

Author
28 Apr 2006 5:09 PM
Rich
create proc stp_errorTest
as
select 1/0

if @@error <> 0
  RAISERROR ('my custom err message', 16, 10)
go

I purposely generate the 'Divide by zero' error.  When I invoke the SP in QA
in get the 'Divide By Zero' message along with my custom message.  Is there a
way to overrid/bypass/trap the Tsql error message and just diplay the custom?

Thanks,
Rich

Author
28 Apr 2006 5:15 PM
Omnibuzz
There is no way of trapping error message in SQL Server 2000 to my knowledge.
In SQL Server 2005, you can use the try catch construct.
Hope this helps
--




Show quote
"Rich" wrote:

> create proc stp_errorTest
> as
>  select 1/0
>
>  if @@error <> 0
>   RAISERROR ('my custom err message', 16, 10)
> go
>
> I purposely generate the 'Divide by zero' error.  When I invoke the SP in QA
> in get the 'Divide By Zero' message along with my custom message.  Is there a
> way to overrid/bypass/trap the Tsql error message and just diplay the custom?
>
> Thanks,
> Rich
Author
28 Apr 2006 5:18 PM
Rich
Thank you.  Just checking.

Show quote
"Omnibuzz" wrote:

> There is no way of trapping error message in SQL Server 2000 to my knowledge.
> In SQL Server 2005, you can use the try catch construct.
> Hope this helps
> --
>
>
>
>
> "Rich" wrote:
>
> > create proc stp_errorTest
> > as
> >  select 1/0
> >
> >  if @@error <> 0
> >   RAISERROR ('my custom err message', 16, 10)
> > go
> >
> > I purposely generate the 'Divide by zero' error.  When I invoke the SP in QA
> > in get the 'Divide By Zero' message along with my custom message.  Is there a
> > way to overrid/bypass/trap the Tsql error message and just diplay the custom?
> >
> > Thanks,
> > Rich
Author
28 Apr 2006 5:22 PM
Aaron Bertrand [SQL Server MVP]
Some errors are too severe for you to trap, since they abort everything.

See http://www.sommarskog.se/ for two excellent texts on error handling.




Show quote
"Rich" <R***@discussions.microsoft.com> wrote in message
news:86B9F710-AC36-4788-A942-2C73C2AFB0F4@microsoft.com...
> create proc stp_errorTest
> as
> select 1/0
>
> if @@error <> 0
>  RAISERROR ('my custom err message', 16, 10)
> go
>
> I purposely generate the 'Divide by zero' error.  When I invoke the SP in
> QA
> in get the 'Divide By Zero' message along with my custom message.  Is
> there a
> way to overrid/bypass/trap the Tsql error message and just diplay the
> custom?
>
> Thanks,
> Rich

AddThis Social Bookmark Button