![]() For example, Magento\InventoryApi\Api\StockSourceLinksDeleteInterface::execute(array $links). An interface name SHOULD reflect the task or action to be performed. Each service interface SHOULD declare a single public method. ![]() Check out web API technical vision for more details.Ħ.4.2.3. Instead, GraphQL SHOULD be used for storefront scenarios. Service contracts SHOULD NOT be used for read scenarios on the storefront. Methods that have similar names MUST serve similar purposes across different services, but they still MAY have different signatures.Ħ.4.2.2. All other APIs, including explicit extension points such as Chain or Composite implementations, MUST be placed under MyModuleApi/Model.Ħ.4.2.1. Directories under MyModuleApi/Api SHOULD NOT be nested.Ħ.4.1.3. Service data interfaces MUST be placed under MyModuleApi/Api/Data. Service interfaces that should be exposed as web APIs MUST be placed under the MyModuleApi/Api directory. For example, if a module is named MyModule, its APIs SHOULD be declared in a module named MyModuleApi.Ħ.4.1.2. API module names must end with the Api suffix. Other modules will depend on the API module, and implementations could be easily swapped via di.xml. Service contract interfaces SHOULD be placed in separate API modules, except when an existing module already contains Service Contracts in the Api folder. Service Contracts (Application) layerĦ.4.1.1. Observer MUST only throw exceptions declared by the method that triggers an event or derived exceptions.Ħ.4. Plugin MUST only throw exceptions declared by the method to which the plugin is added or derived exceptions. Exceptions declared in other components SHOULD NOT be thrown.ĥ.20. Each module or component MUST declare its own exceptions. LocalizedExceptions SHOULD be thrown in the presentation layer only.ĥ.19. Any other types of exceptions MUST be wrapped with LocalizedException before being displayed to the user.ĥ.18. ![]() Exceptions which need to be displayed to the user MUST be sub-types of LocalizedException. In the finally sections, all resources SHOULD be properly released.ĥ.17. 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. The loop SHOULD be wrapped with a try/catch construct instead.ĥ.16. Exceptions SHOULD NOT be caught in a loop. Any exception SHOULD be logged only in the catch block where it is processed, and SHOULD NOT be re-thrown.ĥ.15. It is not allowed to absorb exceptions with no logging or/and any workaround operation executed.ĥ.14. In this case, the original exception must be passed to a new instance with the "previous" argument.ĥ.13. If an exception is caught on the application layer that differs from the one where it has been thrown, and it SHOULD be re-thrown, you SHOULD create a new exception instance that is appropriate for the current layer. It is allowed to throw exceptions that are only defined on the same layer.ĥ.12. A separate exceptions hierarchy SHOULD be defined on each application layer. \Exception SHOULD NOT be thrown in Front Controller and Action Controllers.ĥ.11. ![]() \Exception SHOULD be caught only in the code that calls third-party libraries, in addition to catching specific exceptions thrown by the library.ĥ.10. All direct communications with third-party libraries MUST be wrapped with a try/catch statement.ĥ.9. The top generic \Exception SHOULD NOT be thrown anywhere.ĥ.8. Thrown exceptions SHOULD be as specific as possible. The short name of an exception class MUST be clear, meaningful, and state the cause of exception.ĥ.7. Conditional statements SHOULD be used instead.ĥ.6. Business logic (both application and domain) MUST NOT be managed with exceptions. It is the processing code that decides how to process an exception.ĥ.5. Exceptions MUST NOT handle message output. If a function A calls function B, and function B might throw an exception, this exception MUST be either processed by function A or declared by the annotation in the documentation block of function A.ĥ.4. Exceptions MUST NOT be handled in the same function where they are thrown.ĥ.3. All exceptions that are surfaced to the end user MUST produce error messages in the following format:ĥ.2.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |