use faultbox::{Capture, EventKind, error_chain_of};
use super::context;
use crate::error::ColumnarError;
pub fn memtable_cell_corrupt(err: &ColumnarError, collection: &str) {
let column = match err {
ColumnarError::MemtableCellCorrupt { column, .. } => column.as_str(),
_ => "",
};
let ctx = context::MemtableCellCorrupt {
collection,
column,
detail: err.to_string(),
};
let _ = Capture::new(
EventKind::Corruption,
"columnar memtable cell does not decode, so the read is refused",
)
.error_chain(error_chain_of(err))
.domain(&ctx)
.with_backtrace()
.emit();
}
pub fn wal_row_corrupt(err: &ColumnarError) {
let ctx = context::WalRowCorrupt {
detail: err.to_string(),
};
let _ = Capture::new(
EventKind::Corruption,
"columnar WAL row does not decode, so the decode is refused",
)
.error_chain(error_chain_of(err))
.domain(&ctx)
.with_backtrace()
.emit();
}
pub fn string_cell_not_utf8(err: &ColumnarError) {
let column = match err {
ColumnarError::StringCellNotUtf8 { column, .. } => column.as_str(),
_ => "",
};
let ctx = context::StringCellNotUtf8 {
column,
detail: err.to_string(),
};
let _ = Capture::new(
EventKind::Corruption,
"string column cell is not UTF-8, so the segment write is refused",
)
.error_chain(error_chain_of(err))
.domain(&ctx)
.with_backtrace()
.emit();
}