Error handling and custom error messages

Error handling and custom error messages

Post by Cedomir Markovi » Fri, 11 Jul 2003 10:39:28



How can I get more informations about last error? I get the last error


error, so I can raise the custom error messages for each constraint (like in
MS Access Project).

Chedomir

 
 
 

Error handling and custom error messages

Post by Jacco Schalkwij » Fri, 11 Jul 2003 11:00:59


Don't raise custom user friendly error messages from SQL Server, raise them
from your client application. Any errors are raised from SQL Server to your
client application anyway (there is no way to prevent this) so why would you
want to raise an extra error? In the client application you can parse the
error message (which has the constraint name in it) and raise a user
friendly error to the end user based on that.

For example:
USE Northwind
UPDATE employees SET birthdate = GETDATE()

Will raise the following error message to the client:
Server: Msg 547, Level 16, State 1, Line 1
UPDATE statement conflicted with COLUMN CHECK constraint 'CK_Birthdate'. The
conflict occurred in database 'Northwind', table 'Employees', column
'BirthDate'.
The statement has been terminated.

From which you can get the database, table, column and constraint name if
you need them.

--
Jacco Schalkwijk MCDBA, MCSD, MCSE
Database Administrator
Eurostop Ltd.


> How can I get more informations about last error? I get the last error


> error, so I can raise the custom error messages for each constraint (like
in
> MS Access Project).

> Chedomir


 
 
 

1. Custom Task Error Handling - Displaying Custom Error Message

Hi,

I'm currently working on creating a custom task in VB6.
When it comes to error handling, the recommended error
handling procedure in MSDN is to bubble up the error to
the package event sink using oPackageEvent.onError().
Hence:

--- Sample Code Starts ---

Private Sub CustomTask_Execute(ByVal pPackage As Object,
ByVal pPackageEvents As Object, ByVal pPackageLog As
Object, pTaskResult As DTS.DTSTaskExecResult)
   On Error GoTo errHandler

   ' Business logic
   openConnection(param, param)

   pTaskResult = DTSTaskExecResult_Success
   Exit Sub

errHandler:

   pTaskResult = DTSTaskExecResult_Failure
   if Err.Number=xxxx Then closeConnection

   ' Bubble errors to the package eventsink
   If Not pPackageEvents Is Nothing Then
      pPackageEvents.OnError "CustomTask_Execute method
failed", Err.Number, Err.Source, Err.Description, "",
0, "", True
   End If

   Exit Sub
End Sub

--- Sample Code Ends ---

However, I notice that when error is raised, the specific
error message (Err.Description) will not be displayed on
the DTS Designer execution status dialog box. The only
message I'll get would be "The task reported failure on
execution".

I'm not sure if I have done it correctly. Anyone knows how
to get the custom error messages displayed?

Thanks!

Philip Tan

2. Replikation problem

3. Custom error message in custom Web publishing

4. D3Linux - FAX

5. How to replace SQL Errors with custom Error messages

6. 5.0 form help!!!!

7. Custom Task Error Handling

8. @@IDENTITY and triggers

9. Error Handling Custom

10. Custom Task Error Handling

11. CUSTOM trigger errors NOT handled

12. no custom error handling

13. Custom error handling for HTTPODBC.DLL ??