function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Thiago Barbosa 1Thiago Barbosa 1 

errors in apex?

  public static List<String> setMensagem(String msgInfo, ApexPages.Severity aSeverity){
 		 //ApexPages.Message msg = new ApexPages.Message(aSeverity, msgInfo);
        List<String> lErros = new List<String>();
      	return lErros;

I want to use errors in lightning.
What you have here is a valid method that would return a kind of useless list of strings that contain data you already passed in.  If you want to use this data in lightning, you're probably better off making your error list a class level variable and adding the message to that list.  Then having another method that gets the messages to display on the page.   With that being said, if you're doing this in lightning, I'm not really sure why you would be setting the message from lightning instead of displaying it directly on the page.  If you're setting messages from an apex controller, then you'll want to go with the class level variable route and then display that data in your component.