Overriding standard clarion errors with your own mesage or adding additional errors

Tags: #<Tag:0x00007f687fec1c80> #<Tag:0x00007f687fec1b18>

The GlobalErrors class has support for providing your own messages instead of the standard one.
You can also add your own errors that can be displayed using GlobalErrors.Throw(CustomErrorNumber)

First declare your error group. Generally do this in the global embeds for your data dll or the global embeds of your exe program.

MyErrorGroup Group
  USHORT(3)                           !Set this to the number of errors in the group you are overriding or adding
       USHORT(Msg:ConcurrencyFailed)
       BYTE(Level:Notify)
       PSTRING('Record Was Not Deleted/Updated')
       PSTRING('This record was changed or deleted by another user.')
       USHORT(Msg:RetryAutoInc)
       BYTE(Level:User)
       PSTRING('Auto Increment Error')
       PSTRING('Attempts to automatically number a record for %File have failed.  Error: %ErrorText. Try Again?')
       USHORT(Msg:DeadLock)
       BYTE(Level:Notify)
       PSTRING('Transaction/Operation cancelled')
       PSTRING('Unable to gain necessary locks on %File. Please try operation again. Error: (%ErrorText)')
  End

Next, add the errors to Global Error. If working in the data DLL then use the DLL Initialization embed. I use priority 10,000 so it is at the end.

GlobalErrors.AddErrors(MyErrorGroup)

That’s it. Now any calls to global errors will display your messages.
The MSG:DeadLock is a customer error that I added because the message returned by SQL Server for a dead lock situation is completely non-user friendly.

5 Likes

Additionally, you can edit ABERRORS.TRN in the Libsrc\Win folder to change error messages.

3 Likes