|
|
|
|
|
|
|
|
#include "./options.hpp" |
|
|
#include "./options.hpp" |
|
|
|
|
|
|
|
|
#include <dds/error/errors.hpp> |
|
|
#include <dds/error/errors.hpp> |
|
|
|
|
|
#include <dds/error/toolchain.hpp> |
|
|
#include <dds/util/http/pool.hpp> |
|
|
#include <dds/util/http/pool.hpp> |
|
|
#include <dds/util/log.hpp> |
|
|
#include <dds/util/log.hpp> |
|
|
#include <dds/util/result.hpp> |
|
|
#include <dds/util/result.hpp> |
|
|
|
|
|
|
|
|
dds_log(critical, "Operation cancelled by the user"); |
|
|
dds_log(critical, "Operation cancelled by the user"); |
|
|
return 2; |
|
|
return 2; |
|
|
}, |
|
|
}, |
|
|
[](dds::e_system_error_exc e, neo::url url, http_response_info) { |
|
|
|
|
|
|
|
|
[](e_system_error_exc e, neo::url url, http_response_info) { |
|
|
dds_log(error, |
|
|
dds_log(error, |
|
|
"An error occured while downloading [.bold.red[{}]]: {}"_styled, |
|
|
"An error occured while downloading [.bold.red[{}]]: {}"_styled, |
|
|
url.to_string(), |
|
|
url.to_string(), |
|
|
e.message); |
|
|
e.message); |
|
|
return 1; |
|
|
return 1; |
|
|
}, |
|
|
}, |
|
|
[](dds::e_system_error_exc e, network_origin origin, neo::url* url) { |
|
|
|
|
|
|
|
|
[](e_system_error_exc e, network_origin origin, neo::url* url) { |
|
|
dds_log(error, |
|
|
dds_log(error, |
|
|
"Network error communicating with .bold.red[{}://{}:{}]: {}"_styled, |
|
|
"Network error communicating with .bold.red[{}://{}:{}]: {}"_styled, |
|
|
origin.protocol, |
|
|
origin.protocol, |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
return 1; |
|
|
return 1; |
|
|
}, |
|
|
}, |
|
|
|
|
|
[](e_system_error_exc err, |
|
|
|
|
|
e_loading_toolchain, |
|
|
|
|
|
e_toolchain_file* tc_file, |
|
|
|
|
|
e_toolchain_builtin*) { |
|
|
|
|
|
dds_log(error, "Failed to load toolchain: .br.yellow[{}]"_styled, err.message); |
|
|
|
|
|
if (tc_file) { |
|
|
|
|
|
dds_log(error, " (While loading from file [.bold.red[{}]])"_styled, tc_file->value); |
|
|
|
|
|
} |
|
|
|
|
|
return 1; |
|
|
|
|
|
}, |
|
|
[](e_system_error_exc exc, boost::leaf::verbose_diagnostic_info const& diag) { |
|
|
[](e_system_error_exc exc, boost::leaf::verbose_diagnostic_info const& diag) { |
|
|
dds_log(critical, |
|
|
dds_log(critical, |
|
|
"An unhandled std::system_error arose. THIS IS A DDS BUG! Info: {}", |
|
|
"An unhandled std::system_error arose. THIS IS A DDS BUG! Info: {}", |
|
|
|
|
|
|
|
|
} // namespace |
|
|
} // namespace |
|
|
|
|
|
|
|
|
int dds::handle_cli_errors(std::function<int()> fn) noexcept { |
|
|
int dds::handle_cli_errors(std::function<int()> fn) noexcept { |
|
|
return boost::leaf::try_catch(fn, handlers); |
|
|
|
|
|
|
|
|
return boost::leaf::try_catch( |
|
|
|
|
|
[&] { |
|
|
|
|
|
try { |
|
|
|
|
|
return fn(); |
|
|
|
|
|
} catch (...) { |
|
|
|
|
|
capture_exception(); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
handlers); |
|
|
} |
|
|
} |