File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -100,3 +100,37 @@ the error will be returned in this format as well:
100
100
"hydra:description": "The product \" 1234\" does not exist."
101
101
}
102
102
` ` `
103
+
104
+ # # Fine-grained Configuration
105
+
106
+ The `exception_to_status` configuration can be set on resources and operations :
107
+
108
+ ` ` ` php
109
+ <?php
110
+ // api/src/Entity/Book.php
111
+ namespace App\E ntity;
112
+
113
+ use ApiPlatform\C ore\A nnotation\A piResource;
114
+ use App\E xception\P roductWasRemovedException;
115
+ use App\E xception\P roductNotFoundException;
116
+
117
+ #[ApiResource(
118
+ itemOperations: [
119
+ 'get' => [
120
+ 'exception_to_status' => [
121
+ ProductWasRemovedException::class => 410,
122
+ ],
123
+ ],
124
+ ],
125
+ exceptionToStatus: [
126
+ ProductNotFoundException::class => 404,
127
+ ]
128
+ )]
129
+ class Book
130
+ {
131
+ // ...
132
+ }
133
+ ` ` `
134
+
135
+ Exceptions mappings defined on operations take precedence over mappings defined on resources, which take precedence over
136
+ the global config.
You can’t perform that action at this time.
0 commit comments