File Coverage

blib/lib/SRS/EPP/Response/Error.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             # vim: filetype=perl:noexpandtab:ts=3:sw=3
2             #
3             # Copyright (C) 2009 NZ Registry Services
4             #
5             # This program is free software: you can redistribute it and/or modify
6             # it under the terms of the Artistic License 2.0 or later. You should
7             # have received a copy of the Artistic License the file COPYING.txt.
8             # If not, see <http://www.perlfoundation.org/artistic_license_2_0>
9 1     1   1217 use strict;
  1         1  
  1         29  
10 1     1   4 use warnings;
  1         1  
  1         41  
11              
12             package SRS::EPP::Response::Error;
13 1     1   170 use Moose;
  0            
  0            
14             extends 'SRS::EPP::Response';
15              
16             has 'exception' =>
17             is => 'ro',
18             ;
19              
20             has 'bad_node' =>
21             is => "rw",
22             isa => "XML::LibXML::Node",
23             ;
24              
25             has '+server_id' =>
26             required => 1,
27             ;
28              
29             after 'message_trigger' => sub {
30             my $self = shift;
31             my $bad_node = $self->bad_node;
32             my $result = $self->message->message->result;
33             if ( my $except = $self->exception ) {
34             # permit validation errors to be returned.
35             if ( blessed $except and
36             $except->isa("PRANG::Graph::Context::Error") ) {
37             my $error = XML::EPP::Error->new(
38             value => $except->node,
39             reason => "XML validation error at "
40             .$except->xpath."; "
41             .$except->message,
42             );
43             $result->add_error($error);
44             }
45             }
46             };
47              
48             no Moose;
49             __PACKAGE__->meta->make_immutable;
50              
51             1;
52              
53             __END__
54              
55             =head1 NAME
56              
57             SRS::EPP::Response::Error - EPP exception/error response class
58              
59             =head1 SYNOPSIS
60              
61             #... in a SRS::EPP::Command subclass' ->process() handler...
62             return SRS::EPP::Response::Error->new
63             (
64             id => "XXXX",
65             extra => "...",
66             );
67              
68             =head1 DESCRIPTION
69              
70             This module handles generating errors; the information these can hold
71             is specified in RFC3730 / RFC4930.
72              
73             =head1 SEE ALSO
74              
75             L<SRS::EPP::Response>, L<SRS::EPP::Command>
76              
77             =cut
78              
79             # Local Variables:
80             # mode:cperl
81             # indent-tabs-mode: t
82             # cperl-continued-statement-offset: 8
83             # cperl-brace-offset: 0
84             # cperl-close-paren-offset: 0
85             # cperl-continued-brace-offset: 0
86             # cperl-continued-statement-offset: 8
87             # cperl-extra-newline-before-brace: nil
88             # cperl-indent-level: 8
89             # cperl-indent-parens-as-block: t
90             # cperl-indent-wrt-brace: nil
91             # cperl-label-offset: -8
92             # cperl-merge-trailing-else: t
93             # End: