mb-wrapper icon indicating copy to clipboard operation
mb-wrapper copied to clipboard

Ignore @iconv notice messages

Open pupaxxo opened this issue 6 years ago • 3 comments

pupaxxo avatar Dec 20 '19 09:12 pupaxxo

I'm torn on this one -- on the one hand, the notices are annoying, but on the other hand if there's an actual error being reported in the call to iconv that would suppress it.

iconv is still an annoying function overall, but I'm not convinced this is a good idea particularly because both the mb_convert_encoding and iconv calls can fail if the charset isn't supported. What are your thoughts on suppressing those errors?

zbateson avatar Dec 28 '19 22:12 zbateson

My idea was to suppress iconv notices, they are generally not so much useful, I didn't think about the errors thought... We can catch the errors using the iconv return value, from the PHP documentation it says that iconv return false on failure. We could check for failure and trigger the error only if we are not able to successfully decode it? What do you think?

pupaxxo avatar Dec 28 '19 22:12 pupaxxo

The trouble is catching it means I have to decide on some form of error handling/reporting which I've completely avoided... do I:

  • call trigger_error?
  • throw an exception? I've avoided this everywhere else, so feels out of place
  • log to a psr log? I've also avoided specifically writing logs, although had been thinking of adding that in at a future date to help people with debugging etc since I don't follow either of the above patterns

The other problem is because I've caught the error, I wouldn't have a meaningful message to pass on.

zbateson avatar Jan 02 '20 04:01 zbateson