This routine uses the same `return { success => ..., error => ... }` code everywhere. You should consider simplifying it by using a closure, i.e.:

```perl
my $ret = sub {
    return { success => $_[0], error => $_[1] };
};

# and later...
do_something( ... )
    or return $ret->( 0, "failed to do something" );
```