Skip to content
This repository has been archived by the owner on Nov 19, 2019. It is now read-only.

Script-thrown Exception in TwilioSMS class #59

Open
utkarshugale opened this issue May 20, 2016 · 0 comments
Open

Script-thrown Exception in TwilioSMS class #59

utkarshugale opened this issue May 20, 2016 · 0 comments

Comments

@utkarshugale
Copy link

       Hi,

       Following is piece of my code. When this code is executed, I am getting Script-thrown exception. Any idea what could be wrong config/code here ? I am setting correct 'accountId' & 'authToken' value.



       private static TwilioSMS twilioSms;
       //Creating Twilio Client
        TwilioRestClient client = new TwilioRestClient(accountId, authToken);

        //Adding parameters to send in SMS
        Map<String,String> params = new Map<String,String>();
        params.put('To',phoneNumber);
        params.put('From',fromPhone);
        params.put('Body',textMessage);
        try{
            twilioSms = null;
            twilioSms = client.getAccount().getSMSMessages().create(params);
            System.debug(LoggingLevel.Error,'SMS Sent '+twilioSms);
        }catch(Exception e){
            String exceptionMessage = 'Exception Message: ' + e.getMessage();
            exceptionMessage += '\nTwilio Client Info: ' + client;
            exceptionMessage += '\nTwilio Params Passed: ' + params;
            System.debug(LoggingLevel.ERROR,'Error: '+ exceptionMessage);
            throw new SmsException(exceptionMessage);
        }
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant