feat: Implement client-facing service management API with UUID for services and bulk actions for product services.
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\UniqueConstraintViolationException;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
@@ -34,6 +36,18 @@ class Handler extends ExceptionHandler
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
// Duplicate constraint
|
||||
$this->renderable(function (QueryException $e, $request) {
|
||||
|
||||
if ($e->errorInfo[1] == 1062) {
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => 'Dữ liệu đã tồn tại'
|
||||
], 422);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$this->renderable(function (\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $e, $request) {
|
||||
if (!$request->expectsJson() && !$request->is('v1/*') && !$request->is('api/*')) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user