• santosh lakshminarasappa 1
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
This is the Challenge:

To pass this challenge, create an Apex class that inserts a new account named after an incoming parameter. If the account is successfully inserted, the method should return the account record. If a DML exception occurs, the method should return null.The Apex class must be called 'AccountHandler' and be in the public scope.
The Apex class must have a public static method called 'insertNewAccount'.
The 'insertNewAccount' method must accept an incoming string as a parameter, name the account after the parameter, insert it into the system and then return the account record.
The 'insertNewAccount' method must also accept an empty string, catch the failed DML and return null.


My Class:

public class AccountHandler {

    public static Account insertNewAccount (String accName, Account a) {
         try{   
          a.name = accName;
    
         insert a;
        return a;
        }
        catch(Exception e) {
            return null;
        }
    }    
}



User-added image


Throwing this error, how many times i modified the class.
what is the correct class.?