Skip to content

Conversation

@francoism90
Copy link
Contributor

No description provided.

Copy link
Member

@freekmurze freekmurze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

return new static("Could not find a prefixed model `{$prefixedId}`");
}

public function getSolution(): Solution
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@riasvdv
Copy link
Contributor

riasvdv commented Sep 30, 2021

I'm thinking it might be better to throw Laravel's ModelNotFoundException, as this gets handled into a 404 correctly by default in Laravel.

throw (new ModelNotFoundException())->setModel(static::class);

What do you think @freekmurze?

@francoism90
Copy link
Contributor Author

@riasvdv I was using ModelNotFoundException at first, however you cannot provide a proper getSolution.

Wouldn't it be possible to extend NoPrefixedModelFound with ModelNotFoundException instead of \Exception?

This would make it possible to listen for both exceptions, right? :)

@freekmurze freekmurze merged commit 9a7b592 into spatie:master Oct 1, 2021
@freekmurze
Copy link
Member

Thanks!

@francoism90
Copy link
Contributor Author

@freekmurze Thanks for the merge. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants