Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return of requests is "Error deconding body as JSON: ..." if there is an SerializerException #431

Open
asdfklgash opened this issue Nov 7, 2024 · 1 comment

Comments

@asdfklgash
Copy link

Instead of (re-)throwing a new / the existing exception of JsonSerializer there is a string returned (not everywhere but in some methods):

string(41) "Error decoding body as JSON: Syntax error"

That's a bit tricky as we cannot catch the error and handle it.
So we've also to check the return of a call (i. e. getApi('issue')->show(...)).

@Art4
Copy link
Collaborator

Art4 commented Nov 7, 2024

Hey, this happens mainly for BC reasons while using deprecated methods. If you could tell us how us are using the library I maybe can show you an alternative.

Update: Sorry, I just saw to snippet. The most API classes are returning string|bool on error for BC reasons. This cannot be changed atm without a breaking change and is planned for v3. However I'm planning to implement this as a forward compatible feature by introducing something like a global PHP_REDMINE_API_THROW_EXCEPTIONS = true; constant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants