Closed jacksleight closed 7 months ago
I think I'll do away with the exceptions when "things" can't be found and instead return null
.
Although, since it'd be breaking, I'll do it in v6.
OK great.
In the meantime do you think a composer patch would be the best workaround? Or is there a better temporary fix?
If you need a fix right now, then yeah, a composer patch would probably be best. v6 won't be out for another few weeks at this point.
Created a custom repository in the end:
namespace App\Customers;
use DoubleThreeDigital\SimpleCommerce\Contracts\Customer;
use DoubleThreeDigital\SimpleCommerce\Customers\UserCustomerRepository as BaseUserCustomerRepository;
use DoubleThreeDigital\SimpleCommerce\Exceptions\CustomerNotFound;
class UserCustomerRepository extends BaseUserCustomerRepository
{
public function find($id): ?Customer
{
try {
return parent::find($id);
} catch (CustomerNotFound $e) {
return null;
}
}
}
This will be fixed in v6 (#990).
Description
David's run into an issue with the orders REST API endpoint as a customer/user that's linked to an order has been deleted, so it now throws:
Could this be handled gracefully so that orders without valid customers just exclude that data?
Steps to reproduce
Environment
Statamic Addons: 9 Antlers: runtime Sites: 1 Stache Watcher: Enabled Static Caching: Disabled Version: 4.48.0 PRO
Statamic Addons doublethreedigital/runway: 5.6.1 doublethreedigital/simple-commerce: 5.9.2 duncanmcclean/guest-entries: 3.1.3 jacksleight/statamic-bard-texstyle: 3.1.5 stillat/relationships: 2.1.3 studio1902/statamic-peak-browser-appearance: 3.3.4 studio1902/statamic-peak-commands: 3.2.0 studio1902/statamic-peak-seo: 7.5.0 studio1902/statamic-peak-tools: 4.4.0