• AK D
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Getting as error in the challenge section of Build a Conference Management App - Create a Lightning Component with Server-Side Apex Controller . The error says "There was an unexpected error in your org which is preventing this assessment check from completing: System.QueryException: List has no rows for assignment to SObject". 
This is what the server - side controller looks like: 
public class AttachmentController {
    @AuraEnabled
    public static void updatePicturePath(String recId){
        //In Lightning Experience, Attachments are stored in ContentDocuments
        ContentDocumentLink docLink = [ SELECT ContentDocumentId
                               FROM ContentDocumentLink
                               WHERE LinkedEntityId = :recId order by Id desc Limit 1];
        //ContentVersion Id uniquely identifies the attachment
        ContentVersion ver = [SELECT Id FROM ContentVersion Where ContentDocumentId = :docLink.ContentDocumentId];
        //Update the Picture_Path field with the url of the image
        Speaker__c speaker = [SELECT Id FROM Speaker__c WHERE Id = :recId];
        speaker.Picture_Path__c = '/sfc/servlet.shepherd/version/download/'+ ver.Id;
        upsert speaker;
    }
}
Below code throws error saying: Getting error attempt dereference a  null pointer:

public class AccountHandler {
public class MyException extends Exception{}
public static Account insertNewAccount(String name) {
Account a = new Account();
try
{
    IF(name=='')
    {
    throw new MyException('Empty paramenter');
    }
    else
    {
    a.Name = name;
    insert a;
    return a;
    }
}
catch (DmlException e) {
return null;
}

}
}

what am I missing?