Problem/Motivation
Errors triggered when creating references, namely those caused when entering author names, create very visible error messages, without giving a good indication as to what caused the error.
Steps to reproduce
Create a reference, and in the Authors field enter something like “Mr. Smith”. When you save the reference, you will get a full-page error message due to an ADCI FullNameParser Exception, with a handy-for-developers stack trace. What you don't get is a simple error message on the form indicating “you need to include a first name” or similar.
This also occurs if you enter too many commas in the Author field, either due to a complicated author name, or if the user is trying to enter multiple authors in a single field, separated by commas.
Proposed resolution
The bibcite module should gracefully process the exception, and provide clearer details to the user.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork bibcite-3567338
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
bkosborneI'm a bit puzzled on the best place to catch this exception and bubble it up as a form error. This seems complicated because the exception occurs when the entity autocomplete field tries to auto-create a contributor entity that doesn't exist yet, and the input is invalid.
I think the simplest method may be to add an #element_validate to the contributor field in a form_alter and manually validate the label of the contributor by passing it thru the name parser and check for an exception. Kind of clunky but not sure there's a better way?
Comment #4
bkosborneComment #5
byronveale commentedSee new descriptive error message, I think this should be good to go…
Comment #6
bkosbornelooks good to me
Comment #7
mark_fullmerYes, this looks great. Manual testing also checks out. Thanks!