Skip to content

Commit

Permalink
Fix error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
LinZhihao-723 committed Nov 14, 2024
1 parent 33b21f1 commit 1912615
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion components/core/src/clp/streaming_archive/reader/Segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
#include <sys/stat.h>
#include <unistd.h>

#include <cerrno>
#include <climits>

#include <boost/filesystem.hpp>
#include <fmt/format.h>

#include "../../ErrorCode.hpp"
#include "../../FileReader.hpp"
Expand Down Expand Up @@ -49,11 +51,17 @@ ErrorCode Segment::try_open(string const& segment_dir_path, segment_id_t segment
try {
m_memory_mapped_segment_file.emplace(segment_path);
} catch (TraceableException const& ex) {
auto const error_code{ex.get_error_code()};
auto const formatted_error{
ErrorCode_errno == error_code
? fmt::format("errno={}", errno)
: fmt::format("error_code={}, message={}", error_code, ex.what())
};
SPDLOG_ERROR(
"streaming_archive::reader:Segment: Unable to memory map the compressed "
"segment with path: {}. Error: {}",
segment_path.c_str(),
ex.what()
formatted_error
);
return ErrorCode_Failure;
}
Expand Down

0 comments on commit 1912615

Please sign in to comment.