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
jayaramu Talapalajayaramu Talapala 

Can any one help on this 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

my code is :

public class AccountHandler {

    public static Account insertNewAccount (String accName){
        
        
    if(accName!=''){    
        try{
            Account a = new Account(Name=accName);
            insert a;
            System.debug(' Account created');
            return a;
        } catch(Exception e){
            System.Debug('Account not created');
            return null;
        }
    } else {
        return null;
    }
     
        
    }    
}
Best Answer chosen by jayaramu Talapala
pavan501pavan501
Try this code it will work

public class AccountHandler {
    public static Account insertNewAccount(String name){
        try{
            Account acct = new Account(Name=name);
            insert acct;
            return acct;
        }
        catch(DmlException de){
            System.debug('Exception :'+de.getMessage());
            return null;
        }
    }
}

All Answers

sfdcMonkey.comsfdcMonkey.com
hi jayaramu Talapala
try this ones
 
public class AccountHandler {
public static Account insertNewAccount(String accName) {
Account a = new Account();
a.Name = accName;
try {
insert a;
}
catch (Exception e) {
return null;
}
return a;
}
}
Thanks
let me inform if it work and mark it best answer if it helps you :)
 
pavan501pavan501
Try this code it will work

public class AccountHandler {
    public static Account insertNewAccount(String name){
        try{
            Account acct = new Account(Name=name);
            insert acct;
            return acct;
        }
        catch(DmlException de){
            System.debug('Exception :'+de.getMessage());
            return null;
        }
    }
}
This was selected as the best answer
jayaramu Talapalajayaramu Talapala
Thanks Pavan
Kanhaiya Lal 7Kanhaiya Lal 7
Tried all above still geting the same error,
Challenge not yet complete in Resilient Badger Playground
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

Help me