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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion guides/v2.2/coding-standards/technical-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


## 6. Application layers

Expand Down