From aedf47f8968925738413227ee62f48337e404f45 Mon Sep 17 00:00:00 2001 From: Marc Reichel Date: Sun, 7 Nov 2021 20:58:47 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=85=20Throw=20exception=20when=20image?= =?UTF-8?q?=5Fid=20is=20missing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Exceptions/PropertyDoesNotExist.php | 10 ++++++++++ src/Models/Image.php | 12 +++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/Exceptions/PropertyDoesNotExist.php diff --git a/src/Exceptions/PropertyDoesNotExist.php b/src/Exceptions/PropertyDoesNotExist.php new file mode 100644 index 0000000..d9bd678 --- /dev/null +++ b/src/Exceptions/PropertyDoesNotExist.php @@ -0,0 +1,10 @@ +getAttribute('image_id'); + $id = $this->getAttribute('image_id'); + + if (is_null($id)) { + throw new PropertyDoesNotExist('Property [image_id] is missing from the response. Make sure you specify `image_id` inside the fields attribute.'); + } + + $id = '' . $id; if ($retina) { $size = Str::finish('' . $sizeFromEnum, '_2x');