| 1 | package Eixo::Docker::ContainerException; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use Eixo::Base::Clase qw(Eixo::Rest::BaseException); | ||
| 7 | |||
| 8 | |||
| 9 | my $ERRORS = { | ||
| 10 | 404 => "No such container", | ||
| 11 | 400 => "Bad parameter", | ||
| 12 | 406 => "Impossible to attach (container not running)", | ||
| 13 | 500 => "Server error", | ||
| 14 | }; | ||
| 15 | |||
| 16 | sub ERROR_CODE { | ||
| 17 | |||
| 18 | my $self = $_[0]; | ||
| 19 | |||
| 20 | my $error_code = $self->args->[0]; | ||
| 21 | |||
| 22 | if (exists($ERRORS->{$error_code})){ | ||
| 23 | $self->error($ERRORS->{$error_code}); | ||
| 24 | $self->error_details('Error produced in \''.$self->method.'\' api call. Details: '.join(' - ', @{$self->args})); | ||
| 25 | } | ||
| 26 | else{ | ||
| 27 | |||
| 28 | $self->error("Unknown error code"); | ||
| 29 | $self->error_details("Unknown error code $error_code produced in $self->method") | ||
| 30 | } | ||
| 31 | |||
| 32 | |||
| 33 | } | ||
| 34 |