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

RFC: Injected previous exception into field validation exception #393

Closed

Conversation

alongosz
Copy link
Member

@alongosz alongosz commented Jun 27, 2024

🎫 Issue n/a

Question after reading this: Does this provide enough value?

Description:

Note

The issue in ibexa/migrations, which I was trying to fix, actually no longer exists on 4.x - by accident - due to https://github.com/ibexa/migrations/pull/338. However I still believe this change presents some minor value.

Background

OOTB validation message returned by ContentFieldValidationException::getMessage states "Content fields did not validate".
To avoid lack of verbosity here (user doesn't know where the error actually is) we have there static method createNewWithMultiline,
however it still needs to be called explicitly when handling the exception thrown from some places, while in other places it has been wrapped already. Leaving this as-is due to BC.

Fix

This PR adds the possibility to include previous exception thrown when building new one using ContentFieldValidationException::createNewWithMultiline. Seems it is more correct to do:

try {
 // ...
} catch (ContentFieldValidationException $e) {
  throw ContentFieldValidationException::createNewWithMultiline($e->getFieldErrors(), $contentName, $e);
}

however due to the mentioned migrations fix, provides little actual value - just improving here the exception API itself.

Ideally I would do:

throw ContentFieldValidationException::createNewWithMultiline($e);

but that can't be done due to BC.

Additionally I've fixed broken PHPDoc for ContentService::publishVersion. Long time ago we've added the possibility to validate a content item during publishing instead of a create/update operation, but seems we've forgotten to document an exception that can be thrown.

For QA:

Not reproducible on 4.6 due to the mentioned migrations fix.

Documentation:

Rest API reference change for 4.6, not sure if extra doc action is needed here.

Copy link

@alongosz alongosz changed the title IBX-8458: Injected previous exception into field validation exception Injected previous exception into field validation exception Jun 27, 2024
@alongosz alongosz changed the title Injected previous exception into field validation exception RFC: Injected previous exception into field validation exception Jun 27, 2024
@alongosz alongosz marked this pull request as ready for review June 27, 2024 13:29
@alongosz alongosz requested review from Steveb-p and a team June 27, 2024 13:30
@alongosz
Copy link
Member Author

alongosz commented Sep 4, 2024

Seems we don't need this as it was resolved for 4.6 in a different way. Closing.

@alongosz alongosz closed this Sep 4, 2024
@alongosz alongosz deleted the ibx-8458-improved-content-field-validation-message branch September 4, 2024 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants