File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Exceptions \Data ;
4
+
5
+ /**
6
+ * Use this exception when the data requested by your code was found and it found actually more than expected. A good
7
+ * use for this is the findSingle usual function we find in many library and orm. If you have more than 1 record
8
+ * found, it might mean that you should send back this exception.
9
+ *
10
+ * If the code in context is a service provider that queries a database, this would be the right exception to throw
11
+ * and listen for. The controller on the other hand would catch this and throw a NotFoundException from the Http
12
+ * namespace which would be converted to a standardized message in the front controller.
13
+ *
14
+ * @author Mathieu Dumoulin aka CrazyCodr <[email protected] >
15
+ * @license MIT
16
+ */
17
+ class FoundTooManyException extends DataException
18
+ {
19
+ public function __construct (
20
+ $ message = 'Found too many items in the data source. ' ,
21
+ $ code = 0 ,
22
+ $ previous = null
23
+ ) {
24
+ parent ::__construct ($ message , $ code , $ previous );
25
+ }
26
+ }
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ Data exceptions pertain to all the validation aspect of data and the operations
58
58
- FormatException
59
59
- IntegrityException
60
60
- NotFoundException
61
+ - TooManyFoundException
61
62
- TypeException
62
63
- ValidationException
63
64
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ public function providesConstructorTestClasses()
17
17
[\Exceptions \Data \FormatException::class],
18
18
[\Exceptions \Data \IntegrityException::class],
19
19
[\Exceptions \Data \NotFoundException::class],
20
+ [\Exceptions \Data \FoundTooManyException::class],
20
21
[\Exceptions \Data \TypeException::class],
21
22
[\Exceptions \Data \ValidationException::class],
22
23
[\Exceptions \Http \Client \BadRequestException::class],
You can’t perform that action at this time.
0 commit comments