Callout Exception Messages in Salesforce

Callout Exception Messages in Salesforce

Sample Code:

try {
   
    HTTP h = new HTTP();
    HTTPRequest req = new HTTPRequest();
    req.setEndPoint( 'https://api.github.com/users/hadley/orgs' );
    req.setTimeOut( 1 );
    req.setMethod( 'GET');
    HTTPResponse res = h.send( req ); 
   
}
catch ( System.CalloutException ex ) {
   
    System.debug( 'Error Message is ' + ex.getmessage() );
    system.debug( 'Line Number is ' + ex.getLineNumber() );
    system.debug( 'Stace Trace String is ' + ex.getStackTraceString() );
   
}

Output:

Leave a Reply