<?php
namespace App\Exceptions;
use Illuminate\Http\JsonResponse;
use Throwable;
class ApiErrorResponder
{
    public static function fromThrowable(Throwable $e, int $status = 500): JsonResponse
    {
        return response()->json([
            'success' => false,
            'message' => $e->getMessage() ?: 'Erro interno',
            'data' => null,
        ], $status);
    }
    public static function validation(array $errors, string $message = 'Dados inválidos'): JsonResponse
    {
        return response()->json([
            'success' => false,
            'message' => $message,
            'data' => null,
            'errors' => $errors,
        ], 422);
    }
}
