cloudcreativity / laravel-json-api

JSON API (jsonapi.org) package for Laravel applications.
http://laravel-json-api.readthedocs.io/en/latest/
Apache License 2.0
780 stars 109 forks source link

Exception parser interface has incorrect type-hint #498

Closed Sivanwol closed 4 years ago

Sivanwol commented 4 years ago

i got this issue it print me Symfony\Component\Debug\Exception\FatalThrowableError Argument 1 passed to CloudCreativity\LaravelJsonApi\Exceptions\ExceptionParser::parse() must be an instance of Exception, instance of TypeError given, called in /home/fastwings/Projects/Booksurf/backend/vendor/cloudcreativity/laravel-json-api/src/Exceptions/HandlesErrors.php on line 73 it on the current dev brench. working with laravel 7 but the issue here that i dont know what the error is and why after lot digging i got this Call to a member function toAtomString() on null {"exception":"[object] (Error(code: 0): Call to a member function toAtomString() on null at /home/fastwings/Projects/Booksurf/backend/app/JsonApi/Books/Schema.php:33) [stacktrace] not surewhat this means

mtnntn commented 4 years ago
Call to a member function toAtomString() on null {"exception":"[object] (Error(code: 0): Call to a member function toAtomString() on null at /home/fastwings/Projects/Booksurf/backend/app/JsonApi/Books/Schema.php:33

I don't know if you're still interested in this, anyway it seems that you have a call in your file /home/fastwings/Projects/Booksurf/backend/app/JsonApi/Books/Schema.php that invokes the method toAtomString() from a null object: it's probably related to the function getAttributes($resource) where you're doing something like $resource->property->toAtomString();. Ensure that property is not null :)

lindyhopchris commented 4 years ago

Thanks for reporting this and sorry for slow reply - I've been off work for a few weeks.

The error here is that the Exception parser interface hadn't been updated - it was type-hinting an Exception but actually needs to now type-hint a Throwable instance. I've fixed and this will be tagged as 2.0.0-beta.2.