Lines 21-26
use Mojo::Base 'Mojolicious::Controller';
Link Here
|
21 |
|
21 |
|
22 |
use Koha::City; |
22 |
use Koha::City; |
23 |
use Koha::Cities; |
23 |
use Koha::Cities; |
|
|
24 |
use Koha::Exceptions; |
24 |
|
25 |
|
25 |
use Try::Tiny; |
26 |
use Try::Tiny; |
26 |
|
27 |
|
Lines 40-53
sub list {
Link Here
|
40 |
return $c->render( status => 200, openapi => $cities ); |
41 |
return $c->render( status => 200, openapi => $cities ); |
41 |
} |
42 |
} |
42 |
catch { |
43 |
catch { |
43 |
if ( $_->isa('DBIx::Class::Exception') ) { |
44 |
Koha::Exceptions::rethrow_exception($_); |
44 |
return $c->render( status => 500, |
|
|
45 |
openapi => { error => $_->{msg} } ); |
46 |
} |
47 |
else { |
48 |
return $c->render( status => 500, |
49 |
openapi => { error => "Something went wrong, check the logs."} ); |
50 |
} |
51 |
}; |
45 |
}; |
52 |
|
46 |
|
53 |
} |
47 |
} |
Lines 74-87
sub add {
Link Here
|
74 |
return $c->render( status => 200, openapi => $city ); |
68 |
return $c->render( status => 200, openapi => $city ); |
75 |
} |
69 |
} |
76 |
catch { |
70 |
catch { |
77 |
if ( $_->isa('DBIx::Class::Exception') ) { |
71 |
Koha::Exceptions::rethrow_exception($_); |
78 |
return $c->render( status => 500, |
|
|
79 |
openapi => { error => $_->{msg} } ); |
80 |
} |
81 |
else { |
82 |
return $c->render( status => 500, |
83 |
openapi => { error => "Something went wrong, check the logs."} ); |
84 |
} |
85 |
}; |
72 |
}; |
86 |
} |
73 |
} |
87 |
|
74 |
|
Lines 102-115
sub update {
Link Here
|
102 |
return $c->render( status => 404, |
89 |
return $c->render( status => 404, |
103 |
openapi => { error => "Object not found" } ); |
90 |
openapi => { error => "Object not found" } ); |
104 |
} |
91 |
} |
105 |
elsif ( $_->isa('Koha::Exceptions::Object') ) { |
92 |
Koha::Exceptions::rethrow_exception($_); |
106 |
return $c->render( status => 500, |
|
|
107 |
openapi => { error => $_->message } ); |
108 |
} |
109 |
else { |
110 |
return $c->render( status => 500, |
111 |
openapi => { error => "Something went wrong, check the logs."} ); |
112 |
} |
113 |
}; |
93 |
}; |
114 |
|
94 |
|
115 |
} |
95 |
} |
Lines 129-142
sub delete {
Link Here
|
129 |
return $c->render( status => 404, |
109 |
return $c->render( status => 404, |
130 |
openapi => { error => "Object not found" } ); |
110 |
openapi => { error => "Object not found" } ); |
131 |
} |
111 |
} |
132 |
elsif ( $_->isa('DBIx::Class::Exception') ) { |
112 |
Koha::Exceptions::rethrow_exception($_); |
133 |
return $c->render( status => 500, |
|
|
134 |
openapi => { error => $_->{msg} } ); |
135 |
} |
136 |
else { |
137 |
return $c->render( status => 500, |
138 |
openapi => { error => "Something went wrong, check the logs."} ); |
139 |
} |
140 |
}; |
113 |
}; |
141 |
|
114 |
|
142 |
} |
115 |
} |
143 |
- |
|
|