postgrest_errors 0.1.1 copy "postgrest_errors: ^0.1.1" to clipboard
postgrest_errors: ^0.1.1 copied to clipboard

A generated typed collection of all PostgREST error definitions.

PostgREST errors #

ci coverage pub package License: MIT style: very good analysis


A generated typed collection of all PostgREST error definitions for Dart 🎯

Usage 🧑‍💻 #

Accessing raw PostgREST error data #

The PostgrestError enhanced enumeration provides all documented PostgREST Errors with their code, HTTP Status and description.

PostgrestError.pgrst001.code; // PGRST001
PostgrestError.pgrst001.httpStatus; // 503
PostgrestError.pgrst001.description; // The server is currently unavailable (because it is overloaded or down for maintenance). Generally, this is a temporary state.

Parsing incoming PostgREST exceptions #

Easily parse an incoming PostgREST error response with PostgrestError.fromJson.

import 'dart:convert';

import 'package:http/http.dart' as http;
import 'package:postgrest_errors/postgrest_errors.dart';

void main() async {
  // Make a request to PostgREST server:
  final client = http.Client();
  final response = await client.get(
    Uri.parse('http://localhost:3000'), // PostgREST server
  );

  // Parse the response:
  if (response.statusCode != 200) {
    final json = jsonDecode(response.body) as Map<String, dynamic>;
    throw PostgrestError.fromJson(json);
  }
}
1
likes
130
pub points
0%
popularity
screenshot

Publisher

verified publisheralestiago.com

A generated typed collection of all PostgREST error definitions.

Repository (GitHub)
View/report issues

Topics

#server #backend #postgrest #supabase

Documentation

Documentation
API reference

License

MIT (LICENSE)

Dependencies

postgrest

More

Packages that depend on postgrest_errors