Made the required changes 

Throw custom exception as i mentioned above, so that it can be reused in other handlers. Secondly why you are returning anything from this function. In second line you have thrown an error, so if file exist your code will execute in any ways. So what you can do is write a function which says `ValidateResource` and pass the file name, if file exists next line of code will execute.