package JSON::API::Error;
# ABSTRACT: JSON API-style error objects
use Moo;
use overload bool => sub {1}, '""' => \&to_string;
use Types::Standard qw/Str HashRef/;
our $VERSION = '0.01';
has code
}
sub TO_JSON {
my $self = shift;
my $json = {};
for (qw/code detail id links meta source status title/) {
$json->{$_} = $self->$_ if $self->$_;
}
return $json;
}
1;
__
E
JSON::API::Error - JSON API-style error objects
=head1 SYNOPSIS
use JSON::API::Error;
use Mojo::JSON qw/encode_json/;
# A JSON API error representing bad submission data
my $err = JSON::