mirror of
https://github.com/tstack/lnav.git
synced 2024-10-05 17:17:37 +03:00
[build] catch tz exception
This commit is contained in:
parent
893abf77ec
commit
e7c2535066
10
src/lnav.cc
10
src/lnav.cc
@ -1254,12 +1254,6 @@ looper()
|
||||
log_pipe_err(errpipe[0]);
|
||||
lnav_behavior lb;
|
||||
|
||||
{
|
||||
log_info("BEGIN loading tzdb");
|
||||
date::get_tzdb();
|
||||
log_info("END loading tzdb");
|
||||
}
|
||||
|
||||
ui_periodic_timer::singleton();
|
||||
|
||||
auto mouse_i = injector::get<xterm_mouse&>();
|
||||
@ -2202,7 +2196,7 @@ main(int argc, char* argv[])
|
||||
setenv("LNAV_HOME_DIR", lnav::paths::dotlnav().c_str(), 1);
|
||||
setenv("LNAV_WORK_DIR", lnav::paths::workdir().c_str(), 1);
|
||||
|
||||
{
|
||||
try {
|
||||
auto& safe_options_hier
|
||||
= injector::get<lnav::safe_file_options_hier&>();
|
||||
|
||||
@ -2239,6 +2233,8 @@ main(int argc, char* argv[])
|
||||
};
|
||||
options_hier->foh_path_to_collection.emplace(ghc::filesystem::path("/"),
|
||||
options_coll);
|
||||
} catch (const std::runtime_error& e) {
|
||||
log_error("failed to setup tz: %s", e.what());
|
||||
}
|
||||
|
||||
lnav_data.ld_exec_context.ec_sql_callback = sql_callback;
|
||||
|
@ -409,11 +409,17 @@ com_set_file_timezone(exec_context& ec,
|
||||
lnav::filesystem::write_file(opt_path, coll_str);
|
||||
}
|
||||
} catch (const std::runtime_error& e) {
|
||||
auto note = (date::get_tzdb().zones
|
||||
| lnav::itertools::map(&date::time_zone::name)
|
||||
| lnav::itertools::similar_to(split_args[1])
|
||||
| lnav::itertools::fold(symbol_reducer, attr_line_t{}))
|
||||
.add_header("did you mean one of the following?");
|
||||
attr_line_t note;
|
||||
|
||||
try {
|
||||
note = (date::get_tzdb().zones
|
||||
| lnav::itertools::map(&date::time_zone::name)
|
||||
| lnav::itertools::similar_to(split_args[1])
|
||||
| lnav::itertools::fold(symbol_reducer, attr_line_t{}))
|
||||
.add_header("did you mean one of the following?");
|
||||
} catch (const std::runtime_error& e) {
|
||||
log_error("unable to get timezones: %s", e.what());
|
||||
}
|
||||
auto um = lnav::console::user_message::error(
|
||||
attr_line_t()
|
||||
.append_quoted(split_args[1])
|
||||
@ -441,24 +447,28 @@ com_set_file_timezone_prompt(exec_context& ec, const std::string& cmdline)
|
||||
if (lss != nullptr && lss->text_line_count() > 0) {
|
||||
auto line_pair = lss->find_line_with_file(lss->at(tc->get_selection()));
|
||||
if (line_pair) {
|
||||
static auto& safe_options_hier
|
||||
= injector::get<lnav::safe_file_options_hier&>();
|
||||
try {
|
||||
static auto& safe_options_hier
|
||||
= injector::get<lnav::safe_file_options_hier&>();
|
||||
|
||||
safe::ReadAccess<lnav::safe_file_options_hier> options_hier(
|
||||
safe_options_hier);
|
||||
auto file_zone = date::get_tzdb().current_zone()->name();
|
||||
auto pattern_arg = line_pair->first->get_filename();
|
||||
auto match_res
|
||||
= options_hier->match(line_pair->first->get_filename());
|
||||
if (match_res) {
|
||||
file_zone = match_res->second.fo_default_zone->name();
|
||||
pattern_arg = match_res->first;
|
||||
safe::ReadAccess<lnav::safe_file_options_hier> options_hier(
|
||||
safe_options_hier);
|
||||
auto file_zone = date::get_tzdb().current_zone()->name();
|
||||
auto pattern_arg = line_pair->first->get_filename();
|
||||
auto match_res
|
||||
= options_hier->match(line_pair->first->get_filename());
|
||||
if (match_res) {
|
||||
file_zone = match_res->second.fo_default_zone->name();
|
||||
pattern_arg = match_res->first;
|
||||
}
|
||||
|
||||
retval = fmt::format(FMT_STRING("{} {} {}"),
|
||||
trim(cmdline),
|
||||
date::get_tzdb().current_zone()->name(),
|
||||
line_pair->first->get_filename());
|
||||
} catch (const std::runtime_error& e) {
|
||||
log_error("cannot get timezones: %s", e.what());
|
||||
}
|
||||
|
||||
retval = fmt::format(FMT_STRING("{} {} {}"),
|
||||
trim(cmdline),
|
||||
date::get_tzdb().current_zone()->name(),
|
||||
line_pair->first->get_filename());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1386,10 +1386,14 @@ json_path_handler_base::report_tz_error(yajlpp_parse_context* ypc,
|
||||
.append(lnav::roles::h2("Available time zones"))
|
||||
.append("\n");
|
||||
|
||||
for (const auto& tz : date::get_tzdb().zones) {
|
||||
help_al.append(" ")
|
||||
.append(lnav::roles::symbol(tz.name()))
|
||||
.append("\n");
|
||||
try {
|
||||
for (const auto& tz : date::get_tzdb().zones) {
|
||||
help_al.append(" ")
|
||||
.append(lnav::roles::symbol(tz.name()))
|
||||
.append("\n");
|
||||
}
|
||||
} catch (const std::runtime_error& e) {
|
||||
log_error("unable to load timezones: %s", e.what());
|
||||
}
|
||||
|
||||
ypc->report_error(lnav::console::user_message::error(
|
||||
|
Loading…
Reference in New Issue
Block a user