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

Improve error handling for creating valkyrie collections #5604

Merged
merged 6 commits into from Apr 19, 2022
Merged

Conversation

elrayle
Copy link
Contributor

@elrayle elrayle commented Apr 15, 2022

Description

The new collection instance was being set to the results of the validation failure when it failed and to false when the transactions failed.

WAS:

@collection =
          form.validate(params[collection_params]) &&
          transactions['change_set.create_collection']
          ...
         .call(form).value_or { return after_create_error }

Now, the form validation is processed before setting @collection. If a failure occurs, the process is aborted and calls after_create_errors. Likewise, if there is a failure during the transaction process, after_create_errors is called to process the error and redisplay the new form.

NOTE: This PR also moves after and before methods for create to private, deprecating the public versions. Again, this is consistent with the pattern used in works.

Follow-on work

Need to do the same for updates. This will be done in a separate PR to keep this one easier to review.

Related work

The approach is based on the same change that was made for works in PR #5448.

@samvera/hyrax-code-reviewers

@elrayle elrayle force-pushed the val_col_create branch 2 times, most recently from d0e4744 to 3b2a6dd Compare April 15, 2022 15:47
Copy link
Member

@cjcolvar cjcolvar left a comment

Choose a reason for hiding this comment

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

Looks great!

@cjcolvar cjcolvar merged commit 9148dc0 into main Apr 19, 2022
@cjcolvar cjcolvar deleted the val_col_create branch April 19, 2022 15:05
elrayle added a commit that referenced this pull request Apr 28, 2022
elrayle added a commit that referenced this pull request Apr 28, 2022
elrayle added a commit that referenced this pull request Apr 28, 2022
@elrayle elrayle mentioned this pull request May 3, 2022
@dlpierce dlpierce added the notes-valkyrie Release Notes: Valkyrie specific label Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notes-valkyrie Release Notes: Valkyrie specific
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants