what error checking? it's already in this check:

if(resourceName != null && resourceName != undefined)