12
Views
2
Comments
Solved
How To Catch String or binary data would be truncated
Application Type
Traditional Web
Service Studio Version
11.10.0 (Build 34711)
Platform Version
11.10.0 (Build 22422)

Is there any way to catch the error "String or binary data would be truncated. "? I know why the error is happening, but I need to know which record it is and which attribute. So I want to catch the error and log additional information about it.

I also can't debug this. Because we're talking about 8000+ records and honestly don't want to check every record manually using the debugger.

I also tried to add an AllExceptions handler. But it doesn't get triggered.

Anyone who knows how to catch it?

Rank: #70
Solution

Hi Bo,


The exception has to be triggered on the action where you have the CRUD action (for example, CreatePatient or CreateOrUpdatePatient) and it should be an exception of the DatabaseException type.

My suggestion is to have the handler writing for ServiceCenter (or a table log of your liking) a serialized version of the record so you can examine the record that is causing the error. For instance, in this example, I serialize the record I was trying to write and logging it to ServiceCenter using LogMessage action from System:

Unless you have a table with dozens of columns, it should be easy then to pinpoint which record value is hitting the bar on which column.


Hope it helps.


Regards,
João