This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Try::Tiny; # the best try/catch module | |
use Data::Dumper::Concise; | |
my ( $response, $response_error ); | |
try { | |
$response = method_call_that_might_not_work() | |
} | |
catch($action_error) { | |
# Method call died and did not complete | |
$response_error = $action_error; | |
}; | |
# Method call completed, but was not successful | |
$response_error ||= $response->{error}; | |
if ($response_error) { | |
# Check the data dump is suitable for logging | |
$log->warn("Response failed with '$response_error': ".Dumper($response); | |
# Response to client | |
$c->render( status => 500, text => "Internal Server Error" ); | |
return; | |
} |