getParsedBody(); $output = [ 'input' => $data, 'factura' => null, 'success' => false ]; try { $output['factura'] = $facturaService->add($data); $output['success'] = true; } catch (Implement\Exception\EmptyResult) { $output['error'] = 'No se pudo agregar la factura'; return $this->withJson($response, $output, 400); } return $this->withJson($response, $output); } }