Skip to content

Commit

Permalink
fix fail part
Browse files Browse the repository at this point in the history
  • Loading branch information
temaotl committed Jul 19, 2024
1 parent 32e3d30 commit 359483c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion app/Jobs/EduGainRunMdaScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Jobs;

use App\Traits\HandlesJobsFailuresTrait;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
Expand All @@ -15,6 +16,7 @@
class EduGainRunMdaScript implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use HandlesJobsFailuresTrait;

public string $owner;

Expand Down Expand Up @@ -48,7 +50,7 @@ public function handle(): void
dump($res);

} catch (Exception $e) {
Log::error($e->getMessage());
$this->fail($e);
} finally {
Cache::restoreLock($lockKey, $this->owner)->release();

Expand Down
3 changes: 2 additions & 1 deletion app/Jobs/FolderDeleteEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
class FolderDeleteEntity implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use HandlesJobsFailuresTrait;

/**
* trait with failure function
Expand Down Expand Up @@ -64,7 +65,7 @@ public function handle(): void

RunMdaScript::dispatch($federation, $lock->owner());
} catch (Exception $e) {
Log::error($e->getMessage());
$this->fail($e);
} finally {
if ($lock->isOwnedByCurrentProcess()) {
$lock->release();
Expand Down
5 changes: 3 additions & 2 deletions app/Services/EntityService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Models\Entity;
use App\Models\Federation;
use Exception;
use http\Exception\InvalidArgumentException;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;

Expand Down Expand Up @@ -57,10 +58,10 @@ public function deleteEntityMetadataFromFolder($fileName, $folderName): void
try {
Storage::disk($diskName)->delete($pathToFile);
} catch (Exception $e) {
Log::error("Failed to delete file: {$pathToFile}. Error: ".$e->getMessage());
throw new InvalidArgumentException("Unable to delete file $pathToFile");
}
} else {
Log::warning("File does not exist: {$pathToFile}");
throw new InvalidArgumentException("Unable to delete file $pathToFile");
}

}
Expand Down

0 comments on commit 359483c

Please sign in to comment.