Skip to content
This repository was archived by the owner on Jul 15, 2025. It is now read-only.

Add details to response message on error#58

Merged
backwardspy merged 2 commits intobackwardspy:masterfrom
haffi96:Return-reponse-for-template-validation-errors
Oct 10, 2022
Merged

Add details to response message on error#58
backwardspy merged 2 commits intobackwardspy:masterfrom
haffi96:Return-reponse-for-template-validation-errors

Conversation

@haffi96
Copy link
Copy Markdown
Contributor

@haffi96 haffi96 commented Oct 5, 2022

Return more specific responses for templating errors

For errors in rending a response template:

Example 1: Undefined field used
The following content is used on the response template where typo represents something not accepted in the rendering
"datefield": "{{now() + typo}}"
Response:
image

Example 2: Template syntax error
{"datefield": "{{now()}"}
Response:
image

Questions:

  • Is 406 the right status code for this?
  • This change is just passing the ex into the response. For the cases that I can think to produce, this isn't an issue as it just a one line exception message being passed in. But could we end up with a really long exception message?

closes #48

@backwardspy backwardspy self-assigned this Oct 6, 2022
@backwardspy backwardspy added the enhancement New feature or request label Oct 6, 2022
Copy link
Copy Markdown
Owner

@backwardspy backwardspy left a comment

Choose a reason for hiding this comment

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

looks good so far, thanks for the contribution!

i have put my thoughts down in a comment. please let me know what you think.

@haffi96 haffi96 force-pushed the Return-reponse-for-template-validation-errors branch from 1f98423 to 9a766bd Compare October 9, 2022 20:29
Copy link
Copy Markdown
Owner

@backwardspy backwardspy left a comment

Choose a reason for hiding this comment

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

great work, this looks very nice. i have suggested one more change, after which i'll be happy to merge this.

@haffi96 haffi96 force-pushed the Return-reponse-for-template-validation-errors branch from 9a766bd to ceedfea Compare October 10, 2022 08:36
@backwardspy
Copy link
Copy Markdown
Owner

lgtm!

don't worry about the CI failure, it's still using 3.9 so type union syntax isn't supported yet. i'll bump it to 3.10 on this branch and then merge it all.

thanks for the contribution!

@backwardspy backwardspy force-pushed the Return-reponse-for-template-validation-errors branch from ceedfea to fe9aa03 Compare October 10, 2022 08:53
@backwardspy backwardspy force-pushed the Return-reponse-for-template-validation-errors branch from fe9aa03 to f0f8fd4 Compare October 10, 2022 08:55
@backwardspy backwardspy merged commit 7a4ef68 into backwardspy:master Oct 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

catch template errors and return an informative message in the response body

2 participants