Post by Joe1234 » Fri Dec 27, 2024 3:20 am

Sometimes I'm getting error "PHP Warning: ........: Failed to open stream:...." coming from a specific site that I'm pulling info from through an API. I have other means of handling this error and I don't want my OC error log filling up with this problem.

Is it possible to suppress this error ONLY when it is because of this one website API issue? How?
Or at least specifically which file should I look to edit?

Thanks.

v3.0.4.0 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by softmonke » Fri Dec 27, 2024 2:48 pm

Joe1234 wrote:
Fri Dec 27, 2024 3:20 am
Sometimes I'm getting error "PHP Warning: ........: Failed to open stream:...." coming from a specific site that I'm pulling info from through an API. I have other means of handling this error and I don't want my OC error log filling up with this problem.

Is it possible to suppress this error ONLY when it is because of this one website API issue? How?
Or at least specifically which file should I look to edit?

Thanks.
Have you tried "@" to suppress the warnings? Or you might want to better handle the errors/warnings.

Check out our ever-growing list of extensions for OpenCart here.
Some useful extensions for a better admin experience: Image File Manager ProDrag & Drop Sort Order

Reach out to us at hello@softmonke.com for your OpenCart web development needs or feedback for our extensions.


User avatar
Active Member

Posts

Joined
Tue May 23, 2023 4:42 am


Post by OSWorX » Fri Dec 27, 2024 7:13 pm

I would add a custom error handling.
To start read that: https://www.php.net/manual/en/language.exceptions.php

But it would be for me for more interest why you get this message, "Failed to open stream .." sounds for me that the service/website you are calling has a problem.
Have you tried also other methods to get that content - maybe as fallback?

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Administrator

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by Joe1234 » Sat Dec 28, 2024 1:12 am

@softmonke, that worked perfectly, "@" is a nifty little trick, thanks.
@osworx, the error happens because I'm working on something with a developer account that has a query limit, and that happens when I hit the limit. I have already implemented a fallback api which is why I don't need to be notified of the error. The error happens regardless because it's an http response...from what I understand.

Thanks.

v3.0.4.0 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by OSWorX » Sat Dec 28, 2024 5:37 pm

Joe1234 wrote:
Sat Dec 28, 2024 1:12 am
The error happens regardless because it's an http response...from what I understand.
But to get away from any "error notice", you could check the response (does no matter which kind of request is is) and catch that.
Because I assume that you will need that data ..

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Administrator

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria
Who is online

Users browsing this forum: Semrush [Bot] and 10 guests