Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Update technical-guidelines.md #3871

Merged
merged 2 commits into from
Mar 15, 2019
Merged

Update technical-guidelines.md #3871

merged 2 commits into from
Mar 15, 2019

Conversation

paliarush
Copy link
Contributor

@paliarush paliarush commented Mar 5, 2019

This PR is a:

  • Content fix or rewrite

Summary

When this pull request is merged, it will...

whatsnew
Updated definition of Exceptions 5.17.

@magento-cicd2
Copy link
Contributor

An admin must run tests on this PR before it can be merged.

@dshevtsov dshevtsov self-assigned this Mar 6, 2019
@dshevtsov dshevtsov added 2.2.x 2.3.x Magento 2.3 related changes Major Update Significant original updates to existing content labels Mar 6, 2019
@@ -496,7 +496,7 @@ class View extends Template

5.16. If a method uses system resources (such as files, sockets, streams, etc.), the code MUST be wrapped with a `try` block and the corresponding `finally` block. In the `finally` sections, all resources SHOULD be properly released.

5.17. `LocalizedException` SHOULD only be thrown in the Presentation layer (Controllers, Blocks).
5.17. Exceptions which need to be displayed to the user MUST be sub-types of `LocalizedException`. Any other types of exceptions MUST be wrapped with `LocalizedException` before being displayed to the user.
Copy link
Member

Choose a reason for hiding this comment

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

I think we also want to use LocalizedException only in presentation layer, after change it's not clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We use it in service contracts, which are directly exposed as web API, what is the alternative proposal for service contracts?

Copy link
Member

Choose a reason for hiding this comment

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

We can convert service contract exceptions to LocalizedException before displaying to the user. Can we keep somehow part that LocalizedException should be only be thrown in presentation layer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What will be the conversion rule? We have a hierarchy of LocalizedException classes. Where will the translation be done?

Also this will be backward incompatible change to @api since most service contracts have LocalizedException declared via @throws

@dobooth dobooth assigned dobooth and unassigned dshevtsov Mar 15, 2019
@dobooth
Copy link
Contributor

dobooth commented Mar 15, 2019

running tests

@dobooth dobooth merged commit f5aa20d into magento:master Mar 15, 2019
@ghost
Copy link

ghost commented Mar 15, 2019

Hi @paliarush, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@dshevtsov
Copy link
Collaborator

@dobooth please add whatsnew

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
2.2.x 2.3.x Magento 2.3 related changes Major Update Significant original updates to existing content
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants