mirror of
https://github.com/NotAShelf/stash.git
synced 2026-04-17 08:09:52 +00:00
treewide: improve logging; custom error types with thiserror
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I6a6a696464e4123d15cfaedf4727776e55948369
This commit is contained in:
parent
7dd3db4c88
commit
6e21021306
10 changed files with 221 additions and 166 deletions
|
|
@ -1,14 +1,22 @@
|
|||
use crate::db::{ClipboardDb, SledClipboardDb};
|
||||
use crate::db::{ClipboardDb, SledClipboardDb, StashError};
|
||||
|
||||
use std::io::Read;
|
||||
|
||||
pub trait DeleteCommand {
|
||||
fn delete(&self, input: impl Read);
|
||||
fn delete(&self, input: impl Read) -> Result<usize, StashError>;
|
||||
}
|
||||
|
||||
impl DeleteCommand for SledClipboardDb {
|
||||
fn delete(&self, input: impl Read) {
|
||||
self.delete_entries(input);
|
||||
log::info!("Entries deleted");
|
||||
fn delete(&self, input: impl Read) -> Result<usize, StashError> {
|
||||
match self.delete_entries(input) {
|
||||
Ok(deleted) => {
|
||||
log::info!("Deleted {} entries", deleted);
|
||||
Ok(deleted)
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Failed to delete entries: {}", e);
|
||||
Err(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue