Bladeren bron

More error handling to help diagnose issues in CI

default_compile_flags
vector-of-bool 3 jaren geleden
bovenliggende
commit
5fb021bebf
3 gewijzigde bestanden met toevoegingen van 25 en 10 verwijderingen
  1. +0
    -7
      src/dds/cli/cmd/repoman_add.cpp
  2. +22
    -0
      src/dds/cli/error_handler.cpp
  3. +3
    -3
      src/dds/util/http/pool.cpp

+ 0
- 7
src/dds/cli/cmd/repoman_add.cpp Bestand weergeven

@@ -82,13 +82,6 @@ int repoman_add(const options& opts) {
[](dds::e_system_error_exc e, dds::e_open_repo_db db) {
dds_log(error, "Error while opening repository database {}: {}", db.path, e.message);
return 1;
},
[](dds::e_system_error_exc e, neo::url url, http_response_info) {
dds_log(error,
"An error occured while downloading [.bold.red[{}]]: {}"_styled,
url.to_string(),
e.message);
return 1;
});
}


+ 22
- 0
src/dds/cli/error_handler.cpp Bestand weergeven

@@ -2,6 +2,7 @@
#include "./options.hpp"

#include <dds/error/errors.hpp>
#include <dds/util/http/pool.hpp>
#include <dds/util/log.hpp>
#include <dds/util/result.hpp>
#include <dds/util/signal.hpp>
@@ -10,6 +11,7 @@
#include <boost/leaf/handle_error.hpp>
#include <boost/leaf/handle_exception.hpp>
#include <boost/leaf/result.hpp>
#include <fansi/styled.hpp>
#include <fmt/ostream.h>
#include <json5/parse_data.hpp>
#include <neo/scope.hpp>
@@ -18,6 +20,7 @@
#include <fstream>

using namespace dds;
using namespace fansi::literals;

namespace {

@@ -55,6 +58,25 @@ auto handlers = std::tuple( //
dds_log(critical, "Operation cancelled by the user");
return 2;
},
[](dds::e_system_error_exc e, neo::url url, http_response_info) {
dds_log(error,
"An error occured while downloading [.bold.red[{}]]: {}"_styled,
url.to_string(),
e.message);
return 1;
},
[](dds::e_system_error_exc e, network_origin origin, neo::url* url) {
dds_log(error,
"Network error communicating with .bold.red[{}://{}:{}]: {}"_styled,
origin.protocol,
origin.hostname,
origin.port,
e.message);
if (url) {
dds_log(error, " (While accessing URL [.bold.red[{}]])"_styled, url->to_string());
}
return 1;
},
[](e_system_error_exc exc, boost::leaf::verbose_diagnostic_info const& diag) {
dds_log(critical,
"An unhandled std::system_error arose. THIS IS A DDS BUG! Info: {}",

+ 3
- 3
src/dds/util/http/pool.cpp Bestand weergeven

@@ -410,18 +410,18 @@ request_result http_pool::request(neo::url url, http_request_params params) {

if (resp.is_error()) {
client.discard_body(resp);
throw boost::leaf::exception(http_status_error("Received an error from HTTP"));
throw BOOST_LEAF_EXCEPTION(http_status_error("Received an error from HTTP"));
}

if (resp.is_redirect()) {
client.discard_body(resp);
if (i == 100) {
throw boost::leaf::exception(
throw BOOST_LEAF_EXCEPTION(
http_server_error("Encountered over 100 HTTP redirects. Request aborted."));
}
auto loc = resp.headers.find("Location");
if (!loc) {
throw boost::leaf::exception(
throw BOOST_LEAF_EXCEPTION(
http_server_error("Server sent an invalid response of a 30x redirect without a "
"'Location' header"));
}

Laden…
Annuleren
Opslaan