[Bio] / Sprout / ErrorDocument.pm Repository:
ViewVC logotype

Annotation of /Sprout/ErrorDocument.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (view) (download) (as text)

1 : parrello 1.1 #
2 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
3 :     # for Interpretations of Genomes. All Rights Reserved.
4 :     #
5 :     # This file is part of the SEED Toolkit.
6 :     #
7 :     # The SEED Toolkit is free software. You can redistribute
8 :     # it and/or modify it under the terms of the SEED Toolkit
9 :     # Public License.
10 :     #
11 :     # You should have received a copy of the SEED Toolkit Public License
12 :     # along with this program; if not write to the University of Chicago
13 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
14 :     # Genomes at veronika@thefig.info or download a copy from
15 :     # http://www.theseed.org/LICENSE.TXT.
16 :     #
17 :    
18 :     package ErrorDocument;
19 :    
20 :     use strict;
21 : parrello 1.2 use overload '""' => "baseMessage";
22 : parrello 1.1
23 :     =head1 Error Document
24 :    
25 :     =head2 Introduction
26 :    
27 :     The error document is a simple class that describes a server error. When it is
28 :     exported by the YAML facility, it will be clearly identified as an Error
29 :     Document object, so that the recipient of the data knows something has gone
30 :     wrong.
31 :    
32 : parrello 1.2 This object has been replaced by L<ErrorObject>.
33 :    
34 : parrello 1.1 The fields in this object are as follows.
35 :    
36 :     =over 4
37 :    
38 :     =item function
39 :    
40 :     name of the function that failed
41 :    
42 :     =item message
43 :    
44 : parrello 1.2 detailed message describing the error
45 :    
46 :     =item baseMessage
47 :    
48 :     message describing the kind of error
49 : parrello 1.1
50 :     =back
51 :    
52 :     =cut
53 :    
54 :     =head3 new
55 :    
56 : parrello 1.2 my $errDoc = ErrorDocument->new($function, $message, $baseMessage);
57 : parrello 1.1
58 :     Construct a new ErrorDocument object. The following parameters are expected.
59 :    
60 :     =over 4
61 :    
62 :     =item function
63 :    
64 :     Name of the function that failed.
65 :    
66 :     =item message
67 :    
68 : parrello 1.2 Text of the detailed error message. The detailed error message is long, and frequently
69 :     contains information about where the error occurred and the contents of the call stack.
70 :    
71 :     =item baseMessage
72 :    
73 :     Text of the user-friendly error message. The user-friendly message is short, and
74 :     designed to be minimally confusing; it is also minimally informative.
75 :    
76 : parrello 1.1
77 :     =back
78 :    
79 :     =cut
80 :    
81 :     sub new {
82 :     # Get the parameters.
83 : parrello 1.2 my ($class, $function, $message, $baseMessage) = @_;
84 : parrello 1.1 # Clean the message.
85 :     my $cleaned = $message;
86 :     chomp $cleaned;
87 :     # Create the ErrorDocument object.
88 :     my $retVal = {
89 :     function => $function,
90 :     message => $cleaned,
91 : parrello 1.2 baseMessage => $baseMessage,
92 : parrello 1.1 };
93 :     # Bless and return it.
94 :     bless $retVal, $class;
95 :     return $retVal;
96 :     }
97 :    
98 :     =head2 Public Methods
99 :    
100 :     =head3 message
101 :    
102 :     my $text = $errDoc->message();
103 :    
104 :     Return the error message.
105 :    
106 :     =cut
107 :    
108 :     sub message {
109 :     # Get the parameters.
110 :     my ($self) = @_;
111 :     # Return the result.
112 :     return $self->{message};
113 :     }
114 :    
115 : parrello 1.2 =head3 baseMessage
116 :    
117 :     my $text = $errDoc->baseMessage();
118 :    
119 :     Return the user-friendly error message.
120 :    
121 :     =cut
122 :    
123 :     sub baseMessage {
124 :     # Get the parameters.
125 :     my ($self) = @_;
126 :     # Return the result.
127 :     return $self->{baseMessage};
128 :     }
129 :    
130 : parrello 1.1 =head3 function
131 :    
132 :     my $text = $errDoc->function();
133 :    
134 :     Return the error function.
135 :    
136 :     =cut
137 :    
138 :     sub function {
139 :     # Get the parameters.
140 :     my ($self) = @_;
141 :     # Return the result.
142 :     return $self->{function};
143 :     }
144 :    
145 :    
146 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3