- 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.
public class AccountHandler {
public static Account insertNewAccount(String name) {
Account a = new Account();
a.Name = name;
try {
insert a;
return a;
} catch (Exception e) {
return NULL;
}
}
}
SHOWING ERROR:
Challenge Not yet complete... here's what's wrong: There was an unexpected error in your org which is preventing this assessment check from completing: System.NullPointerException: Attempt to de-reference a null object