postgrestErrorResponse function

Response postgrestErrorResponse({
  1. required int status,
  2. required String message,
  3. String? code,
  4. String? details,
  5. String? hint,
})

Builds a PostgREST-shaped HTTP error for end-to-end adapter tests.

This stays on Bifrost's testing surface: it fabricates the vendor wire envelope but owns no production SQLSTATE/PGRST-to-FailureReason mapping. Supplying the response to a retained Supabase HTTP client exercises the real SDK parse boundary before the app-owned adapter maps the exception.

Implementation

http.Response postgrestErrorResponse({
  required int status,
  required String message,
  String? code,
  String? details,
  String? hint,
}) =>
    jsonResponse(
      <String, Object?>{
        'message': message,
        if (code != null) 'code': code,
        if (details != null) 'details': details,
        if (hint != null) 'hint': hint,
      },
      status: status,
    );