From: tla Date: Tue, 10 Jun 2014 14:48:59 +0000 (+0200) Subject: Avoid Moose typing error if significance not set. Fixes #37 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2Fstemmaweb.git;a=commitdiff_plain;h=995efe7648cfa5cc4d8224a7752c3950d7935e14;hp=196f6e1241a689baca699d703db5f29aefe29d6b Avoid Moose typing error if significance not set. Fixes #37 --- diff --git a/lib/stemmaweb/Controller/Relation.pm b/lib/stemmaweb/Controller/Relation.pm index 7b75c8e..1c3bf8e 100644 --- a/lib/stemmaweb/Controller/Relation.pm +++ b/lib/stemmaweb/Controller/Relation.pm @@ -253,6 +253,7 @@ sub relationships :Chained('text') :PathPart :Args(0) { delete $opts->{scope} unless $opts->{scope}; delete $opts->{annotation} unless $opts->{annotation}; + delete $opts->{is_significant} unless $opts->{is_significant}; $opts->{propagate} = 1; try { @@ -261,7 +262,10 @@ sub relationships :Chained('text') :PathPart :Args(0) { $m->save( $tradition ); } catch( Text::Tradition::Error $e ) { $c->response->status( '403' ); - $c->stash->{'result'} = { 'error' => $e->message }; + $c->stash->{'result'} = { error => $e->message }; + } catch { + $c->response->status( '500' ); + $c->stash->{'result'} = { error => "Something went wrong with the request" }; } } elsif( $c->request->method eq 'DELETE' ) { my $node = $c->request->param('source_id'); @@ -275,7 +279,10 @@ sub relationships :Chained('text') :PathPart :Args(0) { } catch( Text::Tradition::Error $e ) { $c->response->status( '403' ); $c->stash->{'result'} = { 'error' => $e->message }; - } + } catch { + $c->response->status( '500' ); + $c->stash->{'result'} = { error => "Something went wrong with the request" }; + } } } $c->forward('View::JSON'); @@ -395,7 +402,7 @@ sub reading :Chained('text') :PathPart :Args(1) { $errmsg = $e->message; } catch { # Something else went wrong, probably a Moose error - $c->response->status( '403' ); + $c->response->status( '500' ); $errmsg = 'Something went wrong with the request'; } } @@ -579,7 +586,7 @@ sub duplicate :Chained('text') :PathPart :Args(0) { $errmsg = $e->message; } catch { # Something else went wrong, probably a Moose error - $c->response->status( '403' ); + $c->response->status( '500' ); $errmsg = 'Something went wrong with the request'; } if( $newrdg ) {