Commit 6e3a2a5a authored by Ana Rute Mendes's avatar Ana Rute Mendes 🌈
Browse files

Add try/catch in the SnipeHelper calls

Make sure phab won't raise errors if the SnipeHelper methods
or API requests fail.
parent 96045ac4
...@@ -397,7 +397,11 @@ final class ManiphestTransactionEditor ...@@ -397,7 +397,11 @@ final class ManiphestTransactionEditor
// CCU: create Item in the inventory system if it's a Purchase request and // CCU: create Item in the inventory system if it's a Purchase request and
// its status was changed to "to release" // its status was changed to "to release"
if (!$this->getIsNewObject()) { if (!$this->getIsNewObject()) {
try {
$asset_id = $snipe_api->createAssetItem($new_status, $object, $xactions); $asset_id = $snipe_api->createAssetItem($new_status, $object, $xactions);
} catch (Exception $e) {
$asset_id = null;
}
} }
break; break;
} }
...@@ -601,7 +605,11 @@ final class ManiphestTransactionEditor ...@@ -601,7 +605,11 @@ final class ManiphestTransactionEditor
// CCU: if it's a Shipping Request, check if it has an asset item // CCU: if it's a Shipping Request, check if it has an asset item
// in Snipe-IT and automatically fill in some fields. // in Snipe-IT and automatically fill in some fields.
if ($subtype == 'shipping') { if ($subtype == 'shipping') {
try {
$transactions = $snipe_api->fetchAssetItem($object, $xactions); $transactions = $snipe_api->fetchAssetItem($object, $xactions);
} catch (Exception $e) {
$transactions = [];
}
foreach ($transactions as $transaction) { foreach ($transactions as $transaction) {
$results[] = $transaction; $results[] = $transaction;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment