Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
zhztheplayer committed Aug 6, 2024
1 parent 04c6074 commit 988f2f5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion velox/external/date/tz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3577,7 +3577,7 @@ tzdb::locate_zone(const std::string& tz_name) const
return &*zi;
}
#endif // !USE_OS_TZDB
throw std::runtime_error(std::string(tz_name) + " not found in timezone database");
throw invalid_timezone(std::string(tz_name));
}
return &*zi;
}
Expand Down
27 changes: 27 additions & 0 deletions velox/external/date/tz.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,33 @@ ambiguous_local_time::make_msg(local_time<Duration> tp, const local_info& i)
return os.str();
}

class invalid_timezone
: public std::runtime_error
{
public:
invalid_timezone(const std::string tz_name);

private:
static
std::string
make_msg(const std::string tz_name);
};

inline
invalid_timezone::invalid_timezone(const std::string tz_name)
: std::runtime_error(make_msg(tz_name))
{
}

inline
std::string
invalid_timezone::make_msg(const std::string tz_name)
{
std::ostringstream os;
os << tz_name << " not found in timezone database";
return os.str();
}

class time_zone;

#if HAS_STRING_VIEW
Expand Down
2 changes: 1 addition & 1 deletion velox/type/tz/TimeZoneMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ TTimeZoneDatabase buildTimeZoneDatabase(
const date::time_zone* zone;
try {
zone = date::locate_zone(entry.second);
} catch (std::runtime_error& err) {
} catch (date::invalid_timezone& err) {
// Timezone not found in OS, skip it.
LOG(WARNING) << "Timezone [" << entry.second << "] not found due to: '"
<< err.what() << "', ignoring it. ";
Expand Down

0 comments on commit 988f2f5

Please sign in to comment.