Skip to content

Change output errors as JSON when type set to json #165

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

Merged
merged 2 commits into from
Oct 3, 2021

Conversation

menghif
Copy link
Contributor

@menghif menghif commented Oct 3, 2021

Description

Fixes #141

This PR changes the output error to JSON when there is an error and the type is set to json:

{
"error": "User could not be found."
}

Type of change

  • Bug fix (added a non-breaking change which fixes an issue)
  • New feature (added a non-breaking change which adds functionality)
  • Updated documentation (updated the readme, templates, or other repo files)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

  • Tested locally with a valid username
  • Tested locally with an invalid username
  • Ran tests with composer test
  • Added or updated test cases to test new features

Checklist:

  • I have checked to make sure no other pull requests are open for this issue
  • The code is properly formatted and is consistent with the existing code style
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

Screenshots

Copy link
Owner

@DenverCoder1 DenverCoder1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also another error card around line 24 of index.php

…rror message in json when invalid argument is passed.
Copy link
Owner

@DenverCoder1 DenverCoder1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great! Thanks for contributing! 🎉

@menghif
Copy link
Contributor Author

menghif commented Oct 3, 2021

Hey, sorry it's my first time working with PHP but it's a great learning opportunity!
I just added the missing json error output. Let me know if there is anything missing.

@DenverCoder1
Copy link
Owner

It looks good. 👍 Usually I'd recommend putting any code that's repeated into a new function, but we've got #163 open that's taking care of that issue, so hopefully they will be able to incorporate this into their solution as well.

@DenverCoder1 DenverCoder1 merged commit 1ef6384 into DenverCoder1:main Oct 3, 2021
@menghif menghif deleted the issue-141 branch October 3, 2021 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Output errors as JSON when type is set to json
2 participants