<?php

namespace App\Exceptions;

use Exception;

class NotAuthorizedException extends Exception {
    protected $user;

    public function __construct($user) {
        $this->user = $user;
    }

    public function render($request) {
        $path = $request->getPathInfo();

        return response()->json([
            'error' => 'not_authorized',
            'message' => 'El usuario ' . $this->user->id . ' no tiene permiso para acceder al endpoint ' . $path
        ], 401);
    }
}
