I am utilizing Codeigniter.
I have developed a variety of features, and they work perfectly if used as intended.
One such script, a whois script checks the owner of a domain name. If however the user types in an invalid domain name, all sorts of errors are being thrown up here there and everywhere.
For example, if a user types in stack.-com, this is of course not a valid domain. Thus when i call my helper which does the query, no result is return and a variety of errors are returned. There are also errors when i try to display an empty array to the user.
My question relates to errors.
I could use preg_match and check if the domain is valid. If not i set an error variable which i intend to output to the user.
However before my controller gets to the if else statement which decides whether to show the error page or the results page, the program is running queries, and accessing methods to get the data which were there no errors would get the data to pass to the result view.
I.E I know there is an error, but still lots of other errors are being shown because an invalid item is being passed to my other scripts.
With Codeigniter, and the MVC setup, what is the best way of catching the error and displaying it to the user without having to use exceptions which do the same thing over and over again?
Thanks
EDIT WITH IDEA
try
{
$this->load->model('whois');
$this->whois->process('domain.-com');
}
catch
{
$this->load->view('errors',$errordata);
$this->load->view('footer');
die;
}
$this->load->view('normal_content');
$this->load->view('footer');
Is this the suggested setup for using exceptions with codeigniter? within my model, the function will throw exceptions if there is a problem. The catch statement will then display them and die, thus not showing the content.. It does not seem right..?