line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package RapidApp::Responder::UserError; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
1513
|
use Moose; |
|
6
|
|
|
|
|
1288702
|
|
|
6
|
|
|
|
|
54
|
|
4
|
|
|
|
|
|
|
extends 'RapidApp::Responder'; |
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
43873
|
use overload '""' => \&_stringify_static, fallback => 1; # to-string operator overload |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
65
|
|
7
|
6
|
|
|
6
|
|
3105
|
use HTML::Entities; |
|
6
|
|
|
|
|
23239
|
|
|
6
|
|
|
|
|
1248
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
RapidApp::Responder::UserError |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
This "responder" takes advantage of the existing error-displaying codepaths |
16
|
|
|
|
|
|
|
in RapidApp to (possibly) interrupt the current AJAX request and display the |
17
|
|
|
|
|
|
|
message to the user. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
See RapidApp::Sugar for the "die usererr" syntax. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
See RapidApp::View::JSON for the logic this module ties into. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Note that this is considered text, unless it is an instance of RapidApp::HTML::RawHtml |
26
|
|
|
|
|
|
|
has userMessage => ( is => 'rw', isa => 'Str|Object', required => 1 ); |
27
|
0
|
|
|
0
|
0
|
|
sub isHtml { return (ref (shift)->userMessage)->isa('RapidApp::HTML::RawHtml'); } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# same for the title |
30
|
|
|
|
|
|
|
has userMessageTitle => ( is => 'rw', isa => 'Str|Object' ); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub writeResponse { |
33
|
0
|
|
|
0
|
0
|
|
my ($self, $c)= @_; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
$c->stash->{exception} = $self; |
36
|
0
|
|
|
|
|
|
$c->forward('View::RapidApp::JSON'); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
0
|
0
|
|
sub stringify { (shift)->userMessage } |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# This method exists because 'overload' doesn't do dynamic method dispatch |
42
|
|
|
|
|
|
|
# We use a named method (rather than overload '""' => sub { ... }) to improve |
43
|
|
|
|
|
|
|
# readibility of stack traces. |
44
|
0
|
|
|
0
|
|
|
sub _stringify_static { (shift)->stringify } |
45
|
|
|
|
|
|
|
|
46
|
6
|
|
|
6
|
|
88
|
no Moose; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
41
|
|
47
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
48
|
|
|
|
|
|
|
1; |