File tree Expand file tree Collapse file tree 5 files changed +23
-3
lines changed
example_output/errors_all_options Expand file tree Collapse file tree 5 files changed +23
-3
lines changed Original file line number Diff line number Diff line change 1616// mark the cause of the error
1717$ errorSpecApi ->blameJsonPointer ($ pointer ='/data/attributes/title ' );
1818$ errorSpecApi ->blameQueryParameter ($ parameter ='filter ' );
19+ $ errorSpecApi ->blameHeader ($ headerName ='X-Foo ' );
1920
2021// an identifier useful for helpdesk purposes
2122$ errorSpecApi ->setUniqueIdentifier ($ id =42 );
Original file line number Diff line number Diff line change @@ -194,6 +194,15 @@ public function blameQueryParameter($parameter) {
194194 $ this ->addSource ('parameter ' , $ parameter );
195195 }
196196
197+ /**
198+ * blame the header from the request causing this error
199+ *
200+ * @param string $headerName
201+ */
202+ public function blameHeader ($ headerName ) {
203+ $ this ->addSource ('header ' , $ headerName );
204+ }
205+
197206 /**
198207 * @param string $key
199208 * @param mixed $value
Original file line number Diff line number Diff line change 4242 },
4343 "source" : {
4444 "pointer" : " /data/attributes/title" ,
45- "parameter" : " filter"
45+ "parameter" : " filter" ,
46+ "header" : " X-Foo"
4647 },
4748 "meta" : {
4849 "foo" : " bar" ,
6364 "message" : " please don't throw things" ,
6465 "code" : 500 ,
6566 "file" : " /errors_all_options.php" ,
66- "line" : 30
67+ "line" : 31
6768 }
6869 },
6970 {
7374 "message" : " something went wrong!" ,
7475 "code" : 0 ,
7576 "file" : " /errors_all_options.php" ,
76- "line" : 29
77+ "line" : 30
7778 }
7879 },
7980 {
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ public static function createJsonapiDocument() {
1212 $ errorSpecApi = new ErrorObject ();
1313 $ errorSpecApi ->blameJsonPointer ($ pointer ='/data/attributes/title ' );
1414 $ errorSpecApi ->blameQueryParameter ($ parameter ='filter ' );
15+ $ errorSpecApi ->blameHeader ($ headerName ='X-Foo ' );
1516 $ errorSpecApi ->setUniqueIdentifier ($ id =42 );
1617 $ errorSpecApi ->addMeta ($ key ='foo ' , $ value ='bar ' );
1718 $ errorSpecApi ->setHttpStatusCode ($ httpStatusCode =404 );
Original file line number Diff line number Diff line change @@ -160,10 +160,18 @@ public function testIsEmpty_All() {
160160 $ errorObject ->addLink ('foo ' , 'https://jsonapi.org ' );
161161 $ this ->assertFalse ($ errorObject ->isEmpty ());
162162
163+ $ errorObject = new ErrorObject ();
164+ $ errorObject ->addSource ('pointer ' , '/bar ' );
165+ $ this ->assertFalse ($ errorObject ->isEmpty ());
166+
163167 $ errorObject = new ErrorObject ();
164168 $ errorObject ->addSource ('parameter ' , 'bar ' );
165169 $ this ->assertFalse ($ errorObject ->isEmpty ());
166170
171+ $ errorObject = new ErrorObject ();
172+ $ errorObject ->addSource ('header ' , 'X-Bar ' );
173+ $ this ->assertFalse ($ errorObject ->isEmpty ());
174+
167175 $ errorObject = new ErrorObject ();
168176 $ errorObject ->addMeta ('foo ' , 'bar ' );
169177 $ this ->assertFalse ($ errorObject ->isEmpty ());
You can’t perform that action at this time.
0 commit comments