Return 404 if user not found
This commit is contained in:
@@ -3,11 +3,11 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Services\GetRole;
|
||||
use App\Services\UserService;
|
||||
use Propaganistas\LaravelPhone\PhoneNumber;
|
||||
|
||||
@@ -83,7 +83,9 @@ class UserController extends Controller
|
||||
|
||||
try {
|
||||
return response()->json(UserService::getData($id));
|
||||
} catch(\Exception $e) {
|
||||
} catch (ModelNotFoundException $e) {
|
||||
return response()->json(['message' => 'Utilisateur non trouvé'], 404);
|
||||
} catch (\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user