So I catch a DMLException which is caused by a custom exception from a managed package, now how can I get that custom exception?
Here is the log:
18:33:24.391 EXECUTION_STARTED
...
18:33:25.710 SOQL_EXECUTE_BEGIN [35]|Aggregations:0|SELECT Id, Name, DocumentBundleCode__c, Recipient__c FROM DocumentBundle__c WHERE Id = :tmpVar1
18:33:25.710 SOQL_EXECUTE_END [35]|Rows:1
18:33:25.710 USER_DEBUG [165]|DEBUG|### commercialProduct: null
18:33:25.710 EXCEPTION_THROWN [178]|WrtsException: Unable to determine the Template Code/Template Version in order to print item with Id a0k3N0000021LKtQAM
18:33:25.710 EXCEPTION_THROWN [310]|WrtsException: Unable to determine the Template Code/Template Version in order to print item with Id a0k3N0000021LKtQAM
18:33:25.710 EXCEPTION_THROWN [416]|WrtsException: Unable to determine the Template Code/Template Version in order to print item with Id a0k3N0000021LKtQAM
18:33:25.710 SYSTEM_MODE_EXIT false
18:33:25.710 EXCEPTION_THROWN [82]|WrtsException: Unable to determine the Template Code/Template Version in order to print item with Id a0k3N0000021LKtQAM
18:33:25.710 CODE_UNIT_FINISHED MRO_ActivityTrg on Activity trigger event AfterInsert|__sfdc_trigger/MRO_ActivityTrg
18:33:25.710 DML_END [618]
18:33:25.710 EXCEPTION_THROWN [618]|System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, (): []
18:33:25.710 SAVEPOINT_ROLLBACK [642]|SavepointValue1
18:33:25.710 SYSTEM_MODE_EXIT false
18:33:25.710 CODE_UNIT_FINISHED MRO_DossierTrg on Dossier trigger event AfterUpdate|__sfdc_trigger/MRO_DossierTrg
18:33:25.710 DML_END [297]
18:33:25.710 EXCEPTION_THROWN [297]|System.DmlException: Update failed. First exception on row 0 with id a0o3N000001rGwOQAU; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, (): []
18:33:25.710 SYSTEM_MODE_EXIT false
18:33:25.710 USER_DEBUG [4]|DEBUG|System.DmlException
18:33:25.710 CODE_UNIT_FINISHED execute_anonymous_apex
18:33:25.710 EXECUTION_FINISHED
I need to check that the DML was caused exactly by this exception:
WrtsException: Unable to determine the Template Code/Template Version in order to print item with Id a0k3N0000021LKtQAM
18:33:25.710 EXCEPTION_THROWN [310]|
How can I do that without parsing this log? I checked .getCause()
but it's set to null