Skip to content

Commit 41ae55a

Browse files
committed
Refactor exceptions
1 parent 5305e1d commit 41ae55a

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace App\Exceptions;
4+
5+
use Exception;
6+
7+
class CannotLikeReplyMultipleTimes extends Exception
8+
{
9+
protected $message = 'A reply cannot be liked multiple times.';
10+
}

app/Exceptions/CannotLikeReplyTwice.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

app/Jobs/LikeReply.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace App\Jobs;
44

5+
use App\Exceptions\CannotLikeReplyMultipleTimes;
56
use App\User;
67
use App\Models\Reply;
78
use Illuminate\Database\QueryException;
8-
use App\Exceptions\CannotLikeReplyTwice;
99

1010
class LikeReply
1111
{
@@ -42,7 +42,7 @@ public function handle()
4242
try {
4343
$this->reply->likedBy($this->user);
4444
} catch (QueryException $exception) {
45-
throw new CannotLikeReplyTwice('Sorry, you cannot like a reply twice');
45+
throw new CannotLikeReplyMultipleTimes();
4646
}
4747
}
4848
}

0 commit comments

Comments
 (0)