03:10:47.139 (1139188000)|FATAL_ERROR|System.StringException: no protocol: mypersonaldomain.com
I believed I already tested it before and it should work fine.But for sudden I got this error.The snippet of the code is like below :
String str =String)this.controller.getRecord().get('User_Referrer__c');
if(str != null){
URL newURL= new URL(str);
System.debug('newURL:::::: host '+newURL.getHost() );
}
Actually the code break when it want to create new URL.
URL newURL= new URL(str);
The flow is start like this.User_Referrer__c is URL datatype that being inserted by the user.The code will capture the value , create new URL from it.Previously it work fine until one day, I got report that suddenly it break.
So I try to investigate and found out that the value for User_Referrer__c should be http://mypersonaldomain.com instead of mypersonaldomain.com . See how simple http:// will cause the trouble. I updated the value to http://mypersonaldomain.com and it work successfully.
After this, I need to think how to validate the value that entered by user. :)
No comments:
Post a Comment