Where to put generalized logic
Hi all,
are there any best practices for generalized logic?
Specifically, I am currently interested in creating custom exceptions that also accept context information in addition to the simple message
andcode.
In the next step, I would like to extend the error handling to log that context information to improve our error handling.
In my current POC, I created a directory called "Common" in the PYZ namespace (or rather in our own namespace since we extended PYZ again) and inside it an "Exceptions" directory.
Is this way ok, or are there any suggestions for alternative approaches?
Comments
-
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,056 ⚖️ - Guardians (admin)
Hello @benjamin.reuter ,
normally we always find a module where a certain generalized logic could belong to.
For example for the custom exception I could see it belonging to
src/Pyz/(Service|Zed|Client|Shared|Glue)/ErrorHandler
(there is one module without exception class in spryker core) .Or you could do your own util-module like
src/Service/UtilError/
similar to the core util modules:Yet I also see a valid point in your solution. Since this would be used in several other modules it could make sense to make a new hierarchy for that like you did. Because with our module-separation you should ideally not just use it everywhere without injecting it through the dependency provider.
Maybe the "kernel" module could be also suitable for you.
Long story short: There is not the one most correct solution I can offer here.
I still hope this brings you a bit forward. Very interesting question.
All the best,
Florian
1
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 69 Spryker News
- 896 Developer Corner
- 758 Spryker Development
- 83 Spryker Dev Environment
- 361 Spryker Releases
- 3 Oryx frontend framework
- 34 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 23 Job Opportunities
- 3.2K 📜 Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 68 Spryker Safari Questions
- 50 Random