Comments (4)
Hey @funivan, that's a good question! To answer it I'll just remind you that using strict types would raise a Fatal Error (Uncaught TypeError: Argument <argument number> passed to <function> must be of the type <expected type>, <received type> given
).
I'm fine having these kind of fatal errors being raised when passing an invalid argument to a service (as you can see later in the series, like in Event constructor or in AnEventHappened), but when it comes to the entry point of our domain (the Command objects like LandRover
) I'd rather have an InvalidArgumentException
.
I hope that makes sense for you.
from gnugat.github.io.
I understand your position. But what benefits you get when you use InvalidArgumentException instead of type error?
from gnugat.github.io.
Its mainly for error classification: let's say your logic is used in a HTTP application, an API. Then you only need to catch all InvalidArgumentException
and return a 422 UNPROCESSABLE ENTITY
response.
To be fair, instead of throwing \InvalidArgumentException
it might be better to throw a custom MarsRover\Exception\ValidationFailedException
.
from gnugat.github.io.
Thanks. Error classification is good option to choose;)
from gnugat.github.io.
Related Issues (8)
- Console component configuration HOT 3
- Grammar HOT 2
- Atom entry link HOT 3
- Blog broken on HTTPS HOT 7
- Continue the idea HOT 2
- Improve alternatives description HOT 3
- command bus HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gnugat.github.io.