Skip to content
Snippets Groups Projects
Commit 93b90250 authored by Dimitris Bozelos's avatar Dimitris Bozelos
Browse files

Issue #3380371 Corrected exception class

It turns out that the attribute might be missing from some objects of
the same class while being present in others.
parent abb6f634
No related branches found
No related tags found
No related merge requests found
......@@ -21,9 +21,6 @@ class AttributeHelper {
* @throws \RuntimeException
* When the object does not have any attributes, does not have the requested
* attribute, or does not have the value field defined.
* @throws \InvalidArgumentException
* When the object does not have any attributes, or does not have the
* requested attribute.
*/
public static function getValue(string $attribute_id, \stdClass $object) {
if (!isset($object->Attributes)) {
......@@ -63,13 +60,7 @@ class AttributeHelper {
return $attribute->Value->value ?? NULL;
}
// When an attribute is defined on the object's class in Acumatica, the
// objects fetched by API calls contain the attribute object even if it is
// not set on the object. It's just that the value is `NULL` - see above for
// more details on the exact behavior. Thus, if the attribute for the
// requested ID was not found, it must be an error i.e. requesting an
// attribute that does not exist on the object's class.
throw new \InvalidArgumentException(sprintf(
throw new \RuntimeException(sprintf(
'The requested attribute "%s" is not defined on the given object\'s class.',
$attribute_id
));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment