2

I have this code. It still generates an error despite of my catching statement: (max length=5000)
I can't catch this error!
This is my method and how to i catch exception from it:

void FeedSitesMention(Set<Id> setMention, Id parentID){
//do something
    msBodyIn.messageSegments.add(textSegment);
    fInput.body = msBodyIn;
    ConnectApi.BinaryInput binary = null;
    ConnectApi.ChatterFeeds.postFeedItem(null, feedType, subjectId, fInput, binary);

}

It use in another method:

public void someMethod(){
    Try{
        this.FeedSitesMention(setID, ev.id); 
    }catch(Exception e){
       //Do something
    }
}

What's problem?

| improve this question | | | | |
  • Does anything show up in your debug log as a result of this? If so, can you paste it into your question? – alouie Oct 14 '15 at 3:44
  • As I known postFeedItem(null, feedType, subjectId, fInput, binary); is Function of API. I put some debug before and after this function. I just divides it to many part (25 users). but I received the first part. (Salesforce allows 25 users or 25 groups post at the time). what can i do to post many users or groups to chatter? – user3326893 Oct 14 '15 at 6:28
0

I'd expect the Try-catch block you have to only catch an exception that's thrown as a result of your code entering the method you're calling; not where an exception is thrown from within the method after it's been called.

In essence, if you were passing invalid parameters to this.FeedSitesMention(param1, param2), then I'd expect the try-catch block to be able to catch exceptions thrown by things like a NullPointerException or an InvalidParameterValueException the latter referring to a set that's empty or isn't defined to hold Ids.

I'd expect that once you're inside the method, you'll need to have your own exception handling for max length which I don't see in any of the code you've posted.

| improve this answer | | | | |
  • Hi crmprogdev! Thank you for answer my question. I have this idea: I just divides it to many part (25 users). but I received the first part posted to chatter. other parts can't? (Salesforce allows 25 users or 25 groups post at the time). what can i do to post many users or groups to chatter? – user3326893 Oct 14 '15 at 6:27
  • You're welcome. I see that you're adding textSegments which I presume are long text strings with carriage returns (lines). You can count those using string methods. I'm not familiar enough with the Chatter API to respond to the new question in your comments. You may want to post a new question referencing this one. If this post answers the initial question you've asked, please help the rest of the community by marking it as having solved your question. – crmprogdev Oct 14 '15 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.