Use custom message for UNIQUE constraint error message#2879
Use custom message for UNIQUE constraint error message#2879rdwebdesign wants to merge 2 commits into
Conversation
28bd02e to
5a43ef0
Compare
| { | ||
| *message = sqlite3_errmsg(gravity_db); | ||
| if(rc == SQLITE_CONSTRAINT) | ||
| *message = "Item already in the database (UNIQUE constraint failed)"; |
There was a problem hiding this comment.
| *message = "Item already in the database (UNIQUE constraint failed)"; | |
| *message = "Record already present"; |
But maybe native speakers have an even better idea. Would need to be adapted in the other changes, too.
There was a problem hiding this comment.
OK.
The word "database" appears twice. Once on the title and once on the message. We can remove it here.
Also, the "(UNIQUE constraint failed)" can be removed. If was left here because there is code that (in some cases) expects this text, but I don't remember to ever see messages using that code.
I would like to suggest a different text, with "item" instead of "record".
The intention of this change is to return user friendly messages, specially for users without any programming or database background.
What do you think about "The item is already present"?
| *message = "Item already in the database (UNIQUE constraint failed)"; | |
| *message = "The item is already present"; |
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
…ssage Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
c635777 to
144f044
Compare
|
I changed the messages. I force pushed to avoid unnecessary commits. EDIT: I noticed there are many other places showing "UNIQUE constraint failed" on the same 4 yaml files, like these: FTL/src/api/docs/content/specs/clients.yaml Line 167 in 144f044 FTL/src/api/docs/content/specs/clients.yaml Line 437 in 144f044 FTL/src/api/docs/content/specs/clients.yaml Line 460 in 144f044 Should we change all of them? |
What does this PR aim to accomplish?
Currently, when an "UNIQUE constraint" error is found while adding items to group management tables, the returned message is not very user friendly.
This PR uses a custom error message.
Redo of #2878
Suggested in pi-hole/web#3773 (comment)
How does this PR accomplish the above?
Testing the returned error code.
If the error code is
SQLITE_CONSTRAINT(19), we show a custom message.We still show the original message for other error codes.
By submitting this pull request, I confirm the following:
git rebase)