That's actually how civilized people handle errors.
This commit is contained in:
ArthurHoaro 2013-04-04 18:50:02 +02:00
parent 03c1b1d072
commit d685af74ce

View file

@ -22,14 +22,14 @@ function DetectRedirect($url)
{
if(parse_url($url, PHP_URL_HOST)==FALSE) {
//die('Not a URL');
return array( 'error' => 'Not a URL: '. escape ($url) );
throw new Exception('Not a URL: '. escape ($url) );
}
$response = get_headers($url, 1);
if(!empty($response['Location'])) {
$response2 = get_headers($response['Location'], 1);
if(!empty($response2['Location'])) {
//die('too much redirection');
return array( 'error' => 'too much redirection: '. escape ($url) );
throw new Exception('too much redirection: '. escape ($url) );
}
else { return $response['Location']; }
}