duplicateWishlistProduct example

'message' => 'Wishlist is not activated!',
        ];

        yield CustomerException::WISHLIST_NOT_FOUND => [
            'exception' => CustomerException::customerWishlistNotFound(),
            'statusCode' => Response::HTTP_NOT_FOUND,
            'errorCode' => CustomerException::WISHLIST_NOT_FOUND,
            'message' => 'Wishlist for this customer was not found.',
        ];

        yield CustomerException::DUPLICATE_WISHLIST_PRODUCT => [
            'exception' => CustomerException::duplicateWishlistProduct(),
            'statusCode' => Response::HTTP_BAD_REQUEST,
            'errorCode' => CustomerException::DUPLICATE_WISHLIST_PRODUCT,
            'message' => 'Product already added in wishlist',
        ];

        yield CustomerException::LEGACY_PASSWORD_ENCODER_NOT_FOUND => [
            'exception' => CustomerException::legacyPasswordEncoderNotFound('encoder'),
            'statusCode' => Response::HTTP_BAD_REQUEST,
            'errorCode' => CustomerException::LEGACY_PASSWORD_ENCODER_NOT_FOUND,
            'message' => 'Encoder with name "encoder" not found.',
        ];

        
#[Package('core')] class CustomerWishlistProductExceptionHandler implements ExceptionHandlerInterface
{
    public function getPriority(): int
    {
        return ExceptionHandlerInterface::PRIORITY_DEFAULT;
    }

    public function matchException(\Exception $e): ?\Exception
    {
        if (preg_match('/SQLSTATE\[23000\]:.*1062 Duplicate.*uniq.customer_wishlist.sales_channel_id__customer_id\'/', $e->getMessage())) {
            return CustomerException::duplicateWishlistProduct();
        }

        return null;
    }
}
Home | Imprint | This part of the site doesn't use cookies.