new Client/Router/Service arch
[scpubgit/Tak.git] / lib / Tak / Result.pm
CommitLineData
31a246e4 1package Tak::Result;
2
3use Moo;
4
5has type => (is => 'ro', required => 1);
6has data => (is => 'ro', required => 1);
7
8sub get {
9 my ($self) = @_;
10 $self->throw unless $self->type eq 'success';
11 return wantarray ? @{$self->data} : $self->data->[0];
12}
13
14sub throw {
15 my ($self) = @_;
16 die $self->exception;
17}
18
19sub exception {
20 my ($self) = @_;
21 $self->type.': '.join ' ', @{$self->data};
22}
23
241;