Closed officialmmt closed 3 years ago
yes, i have confirm this too.
You can catch it:
try {
$productDescription = \CodesWholesale\Resource\ProductDescription::get($product->getDescriptionHref());
} catch (InvalidArgumentException $e) {
LogService::toFile("DescriptionHref is not found");
}
@fefrik I am testing https://github.com/codeswholesale/codeswholesale-sdk-php/blob/master/examples/single-product-with-description.php this is the same as your answer.
@fefrik I tried live version and real client rather than sandbox credential. And it is work but only with URL.
$product = \CodesWholesale\Resource\ProductDescription::get("https://api.codeswholesale.com/v2/products/cfd6a94d-d497-4251-974d-9b1f2ca640a2/description");
$product->getDescriptionHref() giving no link error like below.
$product = \CodesWholesale\Resource\ProductDescription::get($product->getDescriptionHref());
So how do you handle it?
I'm catching InvalidArgumentException, therefore if there is something wrong with argument, I don't care about description at all and jump over it.
Actually, I am using tripple catch:
try {
$description = $product->getDescriptionHref();
$productDescription = \CodesWholesale\Resource\ProductDescription::get($description);
....
} catch (InvalidArgumentException $e) {
LogService::toFile("DescriptionHref is not found");
} catch (\CodesWholesale\Resource\ResourceError $e) {
if ($e->isInvalidToken()) {
LogService::toFile("ProductDescription Error - Invalid Token. " . $e->getTraceAsString());
// try it once again...
}
} catch (Exception $error) {
LogService::toCatalogFile("ProductDescription Error: " . $error->getMessage());
}
So we getting this error because of we using windows 10 php
no no, this error on linux also (tried on different systems and even macos)
Docker containers have it too.
I trying to print product descriptions but challanging many errors Fatal error: Uncaught InvalidArgumentException: No link in resource description in C:\laragon\www\example\vendor\codeswholesale\sdk\src\CodesWholesale\Resource\Resource.php:38 Stack trace: #0 C:\laragon\www\example\vendor\codeswholesale\sdk\src\CodesWholesale\Resource\Product.php(188): CodesWholesale\Resource\Resource->getHrefRel('description') #1 C:\laragon\www\example\single-product-with-description.php(64): CodesWholesale\Resource\Product->getDescriptionHref() #2 {main} thrown in C:\laragon\www\example\vendor\codeswholesale\sdk\src\CodesWholesale\Resource\Resource.php on line 38