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

Using error struct for additionals data #141

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

MashinaMashina
Copy link

With several nested structures with identical fields, there is no way to understand which error occurred.

This MP, without changing backward compatibility, adds a structure from which you can find out the field name.

If the community wishes, you can include the name in the error message.

@ilyakaznacheev
Copy link
Owner

Hi @MashinaMashina ,

Thanks for the PR. I'm not sure if putting the env name into the error description is the best idea, since env is an optional tag. I'm thinking about something like a path to the variable in the structure.

Not saying your solution is bad or something, it is just not comprehensive. Building a path will solve this problem for all kinds of fields, even lists and maps.

In my head, it looks like a simplified JSONPath format. Something like scruct_field1/list_field2[0]/map_field3[key]/field4.

What do you think?

@ilyakaznacheev ilyakaznacheev added enhancement New feature or request discussion Running discussion labels May 2, 2024
@MashinaMashina
Copy link
Author

MashinaMashina commented May 2, 2024

@ilyakaznacheev
I added the path to the field with which the error occurred.
I tried to do it using []string, but there are rewriting errors in slice or the code becomes too complicated using the copy function.

Example error string: field "Database.Host" is required but the value is not provided

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Running discussion enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants