NAME

WWW::Crawl4AI::Error - structured error class for WWW::Crawl4AI

VERSION

version 0.001

SYNOPSIS

die WWW::Crawl4AI::Error->new(
  type        => 'api',
  message     => "HTTP 503: Service Unavailable",
  response    => $http_response,
  status_code => 503,
  backend     => 'crawl4ai_plain',
);

if (my $e = $@) {
  if (ref $e && $e->isa('WWW::Crawl4AI::Error')) {
    warn "crawl4ai failed (@{[ $e->type ]}): $e" if $e->is_api;
  }
}

DESCRIPTION

Structured error thrown by WWW::Crawl4AI::Client and the strategy chain. Stringifies to its message so it works as a drop-in replacement for a string exception. Carries type, HTTP context, and the responsible backend so callers can route on the specific kind of failure.

type

One of transport, api, job, content. Required.

transport — could not reach the Crawl4AI server at all.
api — the server responded with an HTTP error or malformed body.
job — an async job finished with status FAILED.
content — every strategy ran but no result passed classification (used as the error type of a failed WWW::Crawl4AI::Result).

message

Human-readable error string. Required. The object stringifies to this.

response

The HTTP::Response object, when available.

data

The decoded JSON payload, when available.

status_code

HTTP status code of the Crawl4AI response (0 for pure transport failures).

url

Target URL, when the error is tied to one.

backend

Name of the strategy backend that produced the error, e.g. crawl4ai_plain.

attempt

1-based attempt counter, populated when retry was involved.

is_transport

is_api

is_job

is_content

Boolean accessors, each returns true when "type" matches.

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-www-crawl4ai/issues.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <torsten@raudssus.de> https://raudss.us/

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.