Suppressing an error you know

I know that suppressing errors is a bad idea. That’s why I normally try to debug each error that I come across, but what happens when you’re looking for a URL, but the URL is not valid? Would suppressing it then be a good idea? Let’s say you’re offline and you’re script is looking for http://domain.com/calendar.json. Would it be best to suppress it since you know you’re offline and you keep getting fatal errors saying that the location is not reachable. What if you know the URL exists because you own that URL and you’re just working on a computer that has no internet?

Is it be best to suppress the error or would it be best to remove that part of the code until you upload it to a live server?

I know you guys may say that just use cURL however using cURL doesn’t check to see if the URL is reachable. If it’s not reachable, cURL may throw a blank page or maybe even an error. The idea is to display a custom message if the URL is not reachable either if the user is offline or the URL actually doesn’t exist.

P.S. I’m already using cURL, the idea now is to tell whether the URL is accessible or if it’s not.

1 Like

Ironically, the/a way to check if a URL exists involves suppressing another error: http://stackoverflow.com/questions/2280394/how-can-i-check-if-a-url-exists-via-php#2280413

Yup. I am using list with get_headers and using strpos to check if the header has 404 in it. However, when I start my computer up. I sometimes get fatal errors complaining about the URL not be reachable. But I know for sure that the URL exists because I own it. I believe it’s because when I start up my computer, the internet isn’t turned on and I normally open my browser even before everything starts up.

So to basically remove this error, is it best to suppress it?

no. if you know the reason (offline) then either wait to be online or mock the request. you still can get the error for completely different reasons, even when you’re online, and then you want to be notified about the problem.

Ok. Is it ok to comment out the lines that requests for online objects in the mean time until I get online and then remove the comments so it doesn’t keep making the same errors?

that would get in the way when you commit changes into your versioning system. if you’re developing offline then you should create a fully functional local development environment (e.g. via Virtualbox) so every component you require is available.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.