New answers tagged

2

The main problem in your code is that you're doing a DML and a callout inside of a for-loop. This is a fairly large no-no and is going to cause you to hit Governor limits very quickly. It is also going to cause the error you're seeing. Here you need to do two things: Change your code to do one DML for the entire transaction, see below for an example If the ...


1

Thanks to sfdcfox, I can now understand the cause of the problem. With the Trigger.isExecuting check in, I'm now getting the real error: Error force-app/main/default/contentassets/homepagehero.asset cvnp.ContentDocumentLinkTrigger: execution of AfterInsert caused by: cvnp.SystemErrorException: Event type cvnp__FakeBaseEvent__c not found Class.cvnp.Context:...


1

sfdcfox is quite correct in his answer that you can but shouldn't create your own exception with the same name. It's worth pointing out that in the example you gave, InvalidParameterValueException, you can can construct and throw the system exception e.g. @IsTest private class ThrowSystemExceptionTest { public class ThrowSystemEx { public ...


8

You can, except that if you do so, if any other code anywhere in your code base references that exception, you may get unexpected results. For example, consider: public class DmlException extends Exception { /* Implementation here */ } And somewhere else in your code base: try { insert records; } catch(DmlException e) { /* handle the error */ }...


1

This pattern just isn't going to work. try{ update mapGears.values(); } catch(Exception e){ emailErrorMessageNotification.sendErrorMessage(e.getTypeName(), e.getMessage()); throw e; } If you want the transaction to go through, you cannot re-throw the exception. That will cause a rollback, and the email won't get sent. If you want the email to ...


1

You can test for exceptions like so: Class: myMethod() { try { insert new My_Custom_Object__c(); } catch(DmlException e) { // process error message if you want // throw it throw e; } } Test Class: Important: Test fails if an exception is not thrown by the method being tested in this basic example. It is ...


0

One question to consider is whether you are failing to receive flow exception emails for ALL process builders or if the exception emails are just failing for one particular process builder. I just had a process builder fail. I received an error message in the UI that read: "We can't save this record because the (Object__c) process failed. Give your ...


Top 50 recent answers are included