package Kubernetes::REST::Error;
our $VERSION = '1.107';
# ABSTRACT: Compatibility helper for deprecated v0 error handling
  use Moo;
  use Types::Standard qw/Str/;
  extends 'Throwable::Error';

  has type => (is => 'ro', isa => Str, required => 1);


  has detail => (is => 'ro');


  sub header {
    my $self = shift;
    return sprintf "Exception with type: %s: %s", $self->type, $self->message;
  }


  sub as_string {
    my $self = shift;
    if (defined $self->detail) {
      return sprintf "%s\nDetail: %s", $self->header, $self->detail;
    } else {
      return $self->header;
    }
  }



1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Kubernetes::REST::Error - Compatibility helper for deprecated v0 error handling

=head1 VERSION

version 1.107

=head1 DESCRIPTION

These error classes belong to the deprecated v0 API - the v1 API croaks instead of throwing structured exceptions. They stay around so code that still catches them keeps working.

See L<Kubernetes::REST/"UPGRADING FROM 0.02"> for migration guide.

L<Kubernetes::REST::RemoteError> used to live in this file and now has one of
its own. Loading it from here is not possible - it inherits from this class, so
this file has to finish first - which means code that throws a C<RemoteError>
has to C<use Kubernetes::REST::RemoteError> itself. Code that only catches one
is unaffected.

=head2 type

Error type string.

=head2 detail

Optional detailed error message.

=head2 header

Returns the error header string.

=head2 as_string

Returns the full error message as a string, including detail if available.

=head1 SEE ALSO

=over

=item * L<Kubernetes::REST> - Main API client

=item * L<Kubernetes::REST::RemoteError> - Subclass carrying the HTTP status

=back

=head1 SUPPORT

=head2 Issues

Please report bugs and feature requests on GitHub at
L<https://github.com/pplu/kubernetes-rest/issues>.

=head2 IRC

Join C<#kubernetes> on C<irc.perl.org> or message Getty directly.

=head1 CONTRIBUTING

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

=head1 AUTHORS

=over 4

=item *

Torsten Raudssus <getty@cpan.org>

=item *

Jose Luis Martinez Torres <jlmartin@cpan.org>

=back

=head1 COPYRIGHT AND LICENSE

This software is Copyright (c) 2019-2026 by Jose Luis Martinez Torres <jlmartin@cpan.org>.

This is free software, licensed under:

  The Apache License, Version 2.0, January 2004

=cut
