NAME

Typesense::Client::Error - Exception object thrown by Typesense::Client

SYNOPSIS

use Typesense::Client;

my $ts = Typesense::Client->new(url => '...', api_key => '...');

my $res = eval { $ts->collections->get('products') };
if (my $err = $@) {
    die $err unless ref $err && $err->isa('Typesense::Client::Error');
    say $err->code;                  # 404
    say $err->message;               # Not Found
    say $err->endpoint;              # GET /collections/products
    say "$err";                      # stringifies to the full message
    warn 'server unreachable' if $err->is_connection_error;
}

DESCRIPTION

Every failure raised by Typesense::Client in its default (strict) mode is an object of this class. In fail_open mode the same object is built and stored in $client->last_error, and the method returns undef instead of dying.

The object stringifies to "message_full", so warn $@ and die $@ do the right thing without any unpacking.

METHODS

message

The error text reported by Typesense, or a transport-level description when the request never reached the server.

code

The HTTP status code. Zero means no HTTP response was received at all: DNS failure, connection refused, or timeout. See "is_connection_error".

endpoint

The method and path that failed, e.g. GET /collections/products. Useful in logs where several calls are in flight.

body

The decoded JSON body of the error response, when the server sent one, as a hash reference. undef otherwise.

is_connection_error

True when the request never reached the server (code is 0). This is the case worth retrying or failing open on; a 4xx usually is not.

is_not_found

True for HTTP 404.

message_full

The full message, as produced by stringification.

throw

Typesense::Client::Error->throw(message => '...', code => 404);

Constructs and dies. Used internally by the client.

SEE ALSO

Typesense::Client

AUTHOR

SeHarrys

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by SeHarrys.

This is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.