Skip to content

Commit

Permalink
Err handling at create service
Browse files Browse the repository at this point in the history
  • Loading branch information
maxtropets committed Oct 1, 2024
1 parent e84679e commit 199c0e8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
22 changes: 15 additions & 7 deletions src/node/rpc/node_frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -1509,13 +1509,21 @@ namespace ccf
"Service is already created.");
}

InternalTablesAccess::create_service(
ctx.tx,
in.service_cert,
*this->network.identity->get_key_pair(),
in.create_txid,
in.service_data,
recovering);
try
{
InternalTablesAccess::create_service(
ctx.tx,
in.service_cert,
*this->network.identity->get_key_pair(),
in.create_txid,
in.service_data,
recovering);
}
catch (const std::logic_error& e)
{
return make_error(
HTTP_STATUS_FORBIDDEN, ccf::errors::InternalError, e.what());
}

// Retire all nodes, in case there are any (i.e. post recovery)
InternalTablesAccess::retire_active_nodes(ctx.tx);
Expand Down
9 changes: 5 additions & 4 deletions src/service/internal_tables_access.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ namespace ccf
{
const auto pubkey = ccf::crypto::public_key_pem_from_cert(
ccf::crypto::cert_pem_to_der(prev_service_info->cert));
;

const auto pheaders = {
ccf::crypto::cose_params_string_string(
"from", prev_service_info->current_service_create_txid->to_str()),
Expand All @@ -357,9 +357,10 @@ namespace ccf
}
catch (const ccf::crypto::COSESignError& e)
{
LOG_FAIL_FMT("Failed o sign previous service identity: {}", e.what());
throw; // TO DO catch re-throw in frontent? Or change to log and still
// create service?
LOG_FAIL_FMT(
"Failed to sign previous service identity: {}", e.what());
throw std::logic_error(fmt::format(
"Failed to sign previous service identity: {}", e.what()));
}

// Record number of recoveries for service. If the value does
Expand Down

0 comments on commit 199c0e8

Please sign in to comment.