Skip to content

Commit e00533c

Browse files
author
David Nahodyl
committed
better handling when there are no records to update on a find/update combo
1 parent e38a108 commit e00533c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Services/FileMakerConnection.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,16 @@ protected function performFindAndUpdateResults(FMBaseBuilder $query){
362362
// find the records in the find request query
363363
$findQuery = clone $query;
364364
$findQuery->fieldData = null;
365-
$results = $this->performFind($findQuery);
365+
try {
366+
$results = $this->performFind($findQuery);
367+
} catch (FileMakerDataApiException $e){
368+
if ($e->getCode() === 401){
369+
// no records match request
370+
// we should exit here
371+
// return 0 to show that no records were updated;
372+
return 0;
373+
}
374+
}
366375

367376
$records = $results['response']['data'];
368377
$updatedCount = 0;
@@ -375,7 +384,7 @@ protected function performFindAndUpdateResults(FMBaseBuilder $query){
375384
try{
376385
// Do the update
377386
$this->editRecord($builder);
378-
// Upate if we don't get a record missing exception
387+
// Update if we don't get a record missing exception
379388
$updatedCount++;
380389
} catch (FileMakerDataApiException $e){
381390
// Record is missing is ok for laravel functions

0 commit comments

Comments
 (0)