mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Add nested exception when handle Disk S3 metadata file read error.
This commit is contained in:
parent
72a55c192e
commit
25df6bae78
@ -34,9 +34,9 @@ namespace ErrorCodes
|
||||
extern const int CANNOT_MREMAP;
|
||||
}
|
||||
|
||||
|
||||
Exception::Exception(const std::string & msg, int code)
|
||||
: Poco::Exception(msg, code)
|
||||
/// Aborts the process if error code is LOGICAL_ERROR.
|
||||
/// Increments error codes statistics.
|
||||
void handle_error_code(const std::string & msg, int code) // NOLINT
|
||||
{
|
||||
// In debug builds and builds with sanitizers, treat LOGICAL_ERROR as an assertion failure.
|
||||
// Log the message before we fail.
|
||||
@ -50,6 +50,18 @@ Exception::Exception(const std::string & msg, int code)
|
||||
ErrorCodes::increment(code);
|
||||
}
|
||||
|
||||
Exception::Exception(const std::string & msg, int code)
|
||||
: Poco::Exception(msg, code)
|
||||
{
|
||||
handle_error_code(msg, code);
|
||||
}
|
||||
|
||||
Exception::Exception(const std::string & msg, const Exception & nested, int code)
|
||||
: Poco::Exception(msg, nested, code)
|
||||
{
|
||||
handle_error_code(msg, code);
|
||||
}
|
||||
|
||||
Exception::Exception(CreateFromPocoTag, const Poco::Exception & exc)
|
||||
: Poco::Exception(exc.displayText(), ErrorCodes::POCO_EXCEPTION)
|
||||
{
|
||||
|
@ -25,6 +25,7 @@ class Exception : public Poco::Exception
|
||||
public:
|
||||
Exception() = default;
|
||||
Exception(const std::string & msg, int code);
|
||||
Exception(const std::string & msg, const Exception & nested, int code);
|
||||
|
||||
Exception(int code, const std::string & message)
|
||||
: Exception(message, code)
|
||||
|
@ -175,7 +175,7 @@ struct DiskS3::Metadata
|
||||
if (e.code() == ErrorCodes::UNKNOWN_FORMAT)
|
||||
throw;
|
||||
|
||||
throw Exception("Failed to read metadata file: " + e.message(), ErrorCodes::UNKNOWN_FORMAT);
|
||||
throw Exception("Failed to read metadata file", e, ErrorCodes::UNKNOWN_FORMAT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -729,7 +729,7 @@ void DiskS3::removeMeta(const String & path, AwsS3KeyKeeper & keys)
|
||||
file.remove();
|
||||
}
|
||||
}
|
||||
catch (Exception & e)
|
||||
catch (const Exception & e)
|
||||
{
|
||||
/// If it's impossible to read meta - just remove it from FS.
|
||||
if (e.code() == ErrorCodes::UNKNOWN_FORMAT)
|
||||
@ -738,7 +738,7 @@ void DiskS3::removeMeta(const String & path, AwsS3KeyKeeper & keys)
|
||||
&Poco::Logger::get("DiskS3"),
|
||||
"Metadata file {} can't be read by reason: {}. Removing it forcibly.",
|
||||
backQuote(path),
|
||||
e.message());
|
||||
e.nested() ? e.nested()->message() : e.message());
|
||||
|
||||
file.remove();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user