Stichoza / google-translate-php

🔤 Free Google Translate API PHP Package. Translates totally free of charge.
MIT License
1.79k stars 380 forks source link

Error codes are not present in ErrorException #160

Closed vostreltsov closed 3 years ago

vostreltsov commented 3 years ago

Here:

https://github.com/Stichoza/google-translate-php/blob/a4cb6e279810e29eee2ad09f2356a60d27afe3bd/src/GoogleTranslate.php#L311

the error codes 503/429/413 are omitted.

Please correct me if I am wrong, but having error codes preserved, one could check if updating proxy options (i.e. using a new TOR identity) helps. That's exactly my case right now. Could do a pull-request if my proposal is approved.

BTW thanks for a handy library.

Stichoza commented 3 years ago

Agreed. Currently the error code is only present in the error message itself. I can add it quickly but send a PR if you already have the patch, would be nice to grow the list of contributors 👍🏼