Subject: | DBIC errors are not propagated [PATCH] |
Hi,
in CatalystX::Controller::ExtJS::Direct::API, errors
from DBIC are not propagated to ExtJS.
This patch looks for errors in $c->error after the call to $c->visit()
and - if present - copies the error messages to the ExtJS exception object.
Best Regards
Herbert
Subject: | dbic_errors.patch |
--- lib/CatalystX/Controller/ExtJS/Direct/API.pm 2010-06-19 11:56:23.000000000 +0200
+++ lib/CatalystX/Controller/ExtJS/Direct/newAPI.pm 2010-08-16 18:25:09.610728598 +0200
@@ -139,6 +139,7 @@ sub router {
local $c->{response} = $c->response_class->new({});
local $c->{stash} = {};
local $c->{request} = $c->req;
+ local $c->{error} = undef;
$c->req->parameters($params);
$c->req->body_parameters($params);
@@ -156,7 +157,14 @@ sub router {
$body = $response->body;
}
} or do {
- push(@res, { type => 'exception', tid => $req->{tid}, message => "$@".$c->response->body });
+ my $msg;
+ if(scalar @{ $c->error }){
+ $msg = join "\n", @{ $c->error };
+ }
+ else{
+ $msg = "$@".$c->response->body;
+ }
+ push(@res, { type => 'exception', tid => $req->{tid}, message => $msg });
next REQUESTS;
};