Questions tagged [exception]

An exception denotes an error that disrupts the normal flow of code execution.

Filter by
Sorted by
Tagged with
0
votes
1answer
27 views

You have uncommitted work pending. Please commit or rollback before calling out. Apex Batch

I have a little problem with my batch: List<String> idList; public My_Batch(List<String> ocIdList) { idList= ocIdList; } global Database.QueryLocator start(Database.BatchableContext ...
3
votes
1answer
71 views

“Can only throw this exception type from VisualForce or Aura context” error on sfdx force:source:push

Our CI (Continuous Integration) build has started failing today on the sfdx force:source:push with this error: cvnp.ContentDocumentLinkTrigger: System.LimitException: Can only throw this ...
1
vote
2answers
95 views

Is it fine to create a custom exception class that has the same name as a built in one in apex?

I need to throw exceptions within my apex classes here and there, as most of us do. In fact, we can't throw built-in exceptions so we have to create a custom one that extends from the main exception ...
-1
votes
2answers
40 views

Can't cover DMLException with my test

I'm trying to cover my Exceptionm But I don't know. how to do this. When I try to insert a record without Required fields, I get the System.DmlException: Insert failed. First exception on row 0; first ...
0
votes
0answers
25 views

A callout was unsuccessful because of pending uncommitted work related to a process, flow, or Apex operation [duplicate]

I am trying to write a unit test for my apex class but getting above exception. I am trying to insert a batch of big object records through trigger when the custom object record is inserted. below is ...
0
votes
0answers
22 views

How to extend standard Exception for custom messages and logging in an API?

I have been trying to rewrite some older api - just starting with rewrite of error messages and logging. I saw a lot of duplicated code with error responses and logging, so I decided to separate it ...
1
vote
1answer
51 views

savepoints and rollbacks with future methods - does it rollback changes from other transactions

According to salesforce docs on savepoints and rollbacks: Apex gives you the ability to generate a savepoint , that is, a point in the request that specifies the state of the database at that time. ...
1
vote
1answer
45 views

Throw a DML exceptions in Apex Batch Class for testing

Below is my batch apex class that updates Account object for example: global class abc implements Database.Batchable<sObject>{ global Database.QueryLocator start(Database.BatchableContext ...
1
vote
3answers
42 views

Is it possible to cause an exception on a SOQL select statement?

I'm working on writing tests for someone else's code and they have an try/catch around a SELECT statement. Is it possible to ever get an exception in something like the below code block as long as it ...
1
vote
1answer
135 views

Unable to tunnel through proxy. Proxy returns “HTTP/1.1 503 Service Unavailable”

I'm perfoming a HTTP GET callout to an external cURL connected through proxy, using Postman i get the response. However, while making callout from Salesforce, it gives the following error: System....
0
votes
0answers
18 views

Access Parent inner class using child class name

I was working integration part, so i need to create a few DTO sample to convert JSON to Object and Object to Json. In my case most part of the Json used remains same for different request and ...
0
votes
3answers
36 views

Apex Exception Handling

I created a static method to send exception email to developer name exptonEmail(). I have two classes name Class A and Class B. I am using the exptonEmail method in both class's method in catch block. ...
3
votes
0answers
91 views

Exception.getStackTraceString() returning '()' on object with managed package trigger when debug logs not on

First of all, my question is very similar to this one and might actually be a duplicate, however there is no notion of a managed package or debug logs there. We have an after insert trigger on ...
2
votes
1answer
29 views

What is the correct way to return validation errors from a lightning Apex controller?

What is the correct approach to return validation errors from lightning controller? Suppose we have an aura method that takes some parameters. We need to validate these parameters in order to make ...
4
votes
0answers
40 views

Is this a good Model for “Guaranteeing” Record Updates Don't Fail due to ROW_LOCK/Race Conditions?

Background: The zqu__Quote__c object in our org has two child objects from another managed package we use for eSignature and credit card capture. One of those two child objects collects the Credit ...
3
votes
1answer
266 views

Is it Possible to Catch an Unknown Exception?

I am creating a button that will allow System Admins to reset user passwords via System.resetPassword. We have password restrictions setup such that a password must exist for 24 hours. Therefore, if ...
0
votes
0answers
23 views

Groups object upserting return INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY exception

I use Salesforce SOAP API and try to upsert Groups. I just get data from Salesforce: "LastModifiedDate" -> "2018-04-15T11:35:25.000Z" "SystemModstamp" -> "2018-04-15T11:35:25.000Z" "...
0
votes
2answers
35 views

Catch System.LimitException in Batch to send error via Email

I created a batch that processes data based on certains parameters sent by the user and then sends the result via email. But sometimes the parameters are too ambitious and the batch throws a System....
9
votes
4answers
127 views

Run more than one async jobs from Future/Quable context

We have created a process which must work asynchronously (limits and architecture reasons) and it was working fine. Some time later we have started to work with BigObject. And as long as writing to ...
0
votes
1answer
56 views

How do I check if a list-value from my Map is empty?

I get this error in case if Opportunity__c has no OpportunityInfo__c. I try to check it with the condition if(opportunitiesMap.get(actualTool.Rent__r.Opportunity__c).OpportunityInfo__r != null), but ...
0
votes
1answer
21 views

Custom exception on Service Response with Standard API

Using standard API, when i receive a POST, if things go wrong i must return an error response. Since i'm not using a custom web service but a TriggerHandler, when one of the required parameters isn't ...
0
votes
1answer
32 views

Cannot bypass 'Duplicate Username' Salesforce error on before insert User Trigger

As per standard functionality, when one tries to create/update a user record with a username value that is NOT unique across all Salesforce orgs, then the following error message is returned: ...
0
votes
0answers
122 views

How to fix exception-field integrity exception: Type, Quantity, unknown

I am getting the error ( field integrity exception: Type, Quantity, unknown ) while creating an opportunity line item schedule in a flow in production. I am unable to reproduce this issue in sandbox. ...
1
vote
0answers
32 views

Callout Exception when testing

I use a webservice to validate government info on companies. This is used for accounts and Cases. For some reason I'm getting this calloutException but there's no DML before the callout. I'm getting ...
2
votes
1answer
98 views

How to stop Code executing once I catch an exception?

I am attempting to display an error message on a VF page if I get a time out error from an api call. I am using try catch, to get to the exception, but I would like to stop further code execution ...
-1
votes
1answer
31 views

Error Handling in methods that return account

I have an Apex method that receives an Account record as input and returns Account record. What if an error occurs and i want to return it to the user? I cannot return String, since the method returns ...
0
votes
1answer
110 views

Can't get Platform Event Retries to work?

I am not seeing any evidence that processing continues after I raise a EventBus.RetryableException. Logs indicate the retry event is thrown, then nothing. My test class, which is the same as ...
2
votes
1answer
55 views

How to disable constructors in custom exceptions?

There is a lot out there on how you can't override exception constructors and how to do custom exceptions, but I haven't been able to find anything on disabling a constructor for an extended class. I'...
0
votes
2answers
55 views

Why catch code of an try catch exception are not executed when System.LimitException: Too many DML statements: 151

I have the next code block that generates a limitException: Account myAccount = new Account(Name = 'MyAccount'); Insert myAccount; For (Integer x = 0; x < 150; x++) {Account newAccount = new ...
0
votes
0answers
414 views

sfdx force:source:deploy fails with UNKNOWN_EXCEPTION

Yesterday it worked, but when I deploy my DX projects to my Sandbox using sfdx force:source:deploy -p ./force-app -l RunLocalTests -u TargetOrg -w 15 it fails with: === Component Failures [1] TYPE ...
0
votes
0answers
82 views

System.DmlException: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, A workflow or approval field update caused an error when saving this record in Apex

Full Error message: System.DmlException: Process failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, A workflow or approval field update caused an error when saving ...
4
votes
0answers
98 views

Getting full stack trace in BatchApexErrorEvent

I am using the BatchApexErrorEvent to get the stack trace of the exception but it only gives the line from where the issue is generated. { ReplayId=12, CreatedDate=2019-06-18 12:45:24, ...
0
votes
1answer
27 views

SObjectException

As per my understanding, the below code should throw System.SObjectException: SObject row was retrieved via SOQL without querying the requested field, but instead it updated the account phone without ...
-1
votes
1answer
71 views

Database.Upsert not able to prevent AllOrNone

Elaborating the Question:- We have 3 Objects, Branch, Account and Branch Accounts, Branch Accounts is a junction between former 2. Now we are trying to insert Branch Account records via Batch, and in ...
2
votes
1answer
57 views

How to send debug log with email

Assume that We have try catch structure and if exception throw, I want to send all debug log in email as an attachment. Is that possible?
0
votes
0answers
40 views

exception when sending email from Apex when setWhatId is set with recordId

i'm getting an exception when sending email from apex controller class. I'm associating this email with recordId to show it under activity for that record. here is the exception System....
0
votes
1answer
22 views

Unable to update existing(Or) related leads while lead convertion

Currently, I'm working on the parent-child relationship on the lead object. So, we are restricting users to convert only master lead & then top 20 related leads will be converting as contacts to ...
1
vote
0answers
44 views

Reload Visualforce page on session lost

Im trying to reload a Visualforce page when session is lost, due to another login, and sessionId created in a different browser tab. I have code that makes constant calls to the controller methods, ...
3
votes
1answer
466 views

What are “LOB fields” in an asset? Querying all the fields on the asset causes a limit exception, why?

First of all: what are LOB fields? Secondly: I have a complex apex automated process in which I need to make an exact copy of an Asset object (all of its fields). To do this I created a method that ...
8
votes
0answers
112 views

Rethrowing an exception is missing the stackTraceString

I have code that is wrapped into a main try-catch block and then inside of that I have another try-catch which I am using for a specific use case. If the inner try-catch gets triggered I then use a ...
0
votes
2answers
275 views

Create exceptions in test classes for a process builder?

Is is possible to create exceptions in a Test Class for (example) Process Builder "XYZ NAME"? To avoid the test class running that process. Right now my work-around is to manipulate the criteria in ...
8
votes
3answers
443 views

How to Aura Handle multiple DmlExceptions

How should I handle multiple DmlException messages when using AuraHandledException inside an Apex Controller. If I do this: try { upsert value; } catch(DmlException e) { throw new ...
1
vote
3answers
934 views

System.AsyncException: Maximum stack depth has been reached. while writing in test class

I've got a requirement to perform queueable apex in a trigger my class working fine, but while writing a test class for queueable apex I'm getting an exception. Could anybody can help me. Trigger ...
2
votes
1answer
57 views

How to throw or cause an Access Level exception in a test class

anyone know how to throw an access level exception in a test class to cover the below code sample? I'm assuming the object being inserted with Database.insert needs to have sharing settings modified ...
0
votes
0answers
323 views

Exception method getStackTraceString is empty ()

I'm sending any errors that our try/catch blocks catch to Slack and for some reason all the Exception info is filled out apart from the getStackTraceString method. It's a method within a class: try {...
1
vote
2answers
203 views

Insufficient access issue while deleting the record with Public Read/Write sharing settings

User is getting "There's a problem saving this record. You might not have permission to edit it, or it might have been deleted or archived. Contact your administrator for help." exception for a record....
1
vote
2answers
62 views

Cover Error Handling on Test Class

I am having an issue where I have a trigger that rolls up data from contacts to an account. This was working fine with no issues until we added a managed package app that is constantly checking and ...
0
votes
0answers
98 views

@future method not getting called from catch block

I am calling a webservice (synchronous) and in case of CalloutException, I'm trying to create an error log in a custom object. The problem is, the record insertion is happening in a future method and ...
1
vote
2answers
296 views

Exception not being caught; System.FinalException: Cannot modify a collection while it is being iterated

Why is this Exception not being caught? I read that System.LimitException is not caught but didn't see anywhere about System.FinalException. Non-Working Code @AuraEnabled public static List<...
0
votes
1answer
646 views

Read Time Out Exception

I am calling REST API method to update some data to another system from apex but getting "common.apex.runtime.impl.ExecutionException: Read timed out" exception. Here is my request code HttpRequest ...

1
2 3 4 5
10