mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-03 07:55:13 +00:00
improve envelope list query error diagnostics
This commit is contained in:
parent
1e7adc5e0c
commit
46bf3eebfc
|
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed watch IMAP envelopes when folder was empty [#179].
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Changed the `envelope list` options:
|
- Changed the `envelope list` options:
|
||||||
|
|
5
Cargo.lock
generated
5
Cargo.lock
generated
|
@ -635,8 +635,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chumsky"
|
name = "chumsky"
|
||||||
version = "1.0.0-alpha.6"
|
version = "1.0.0-alpha.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/zesterer/chumsky.git?rev=6837537#68375371a5fde6ee14f190c14e9a9cee0697f022"
|
||||||
checksum = "b9c28d4e5dd9a9262a38b231153591da6ce1471b818233f4727985d3dd0ed93c"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
"regex-automata 0.3.9",
|
"regex-automata 0.3.9",
|
||||||
|
@ -1219,7 +1218,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "email-lib"
|
name = "email-lib"
|
||||||
version = "0.22.3"
|
version = "0.22.3"
|
||||||
source = "git+https://git.sr.ht/~soywod/pimalaya#79af9b0fa5fb30dcb1f8fbd322f7e40b9e05053a"
|
source = "git+https://git.sr.ht/~soywod/pimalaya#17838306e588fd1382da4b49ec1ed9ff846f33f0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"advisory-lock",
|
"advisory-lock",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
|
|
@ -92,3 +92,4 @@ version = "0.1"
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
email-lib = { git = "https://git.sr.ht/~soywod/pimalaya" }
|
email-lib = { git = "https://git.sr.ht/~soywod/pimalaya" }
|
||||||
|
chumsky = { git = "https://github.com/zesterer/chumsky.git", rev = "6837537" }
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use ariadne::{Color, Label, Report, ReportKind, Source};
|
use ariadne::{Color, Label, Report, ReportKind, Source};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use email::{backend::feature::BackendFeatureSource, envelope::list::ListEnvelopesOptions};
|
use email::{
|
||||||
|
backend::feature::BackendFeatureSource, envelope::list::ListEnvelopesOptions,
|
||||||
|
search_query::SearchEmailsQuery,
|
||||||
|
};
|
||||||
use log::info;
|
use log::info;
|
||||||
|
use std::process::exit;
|
||||||
|
|
||||||
#[cfg(feature = "account-sync")]
|
#[cfg(feature = "account-sync")]
|
||||||
use crate::cache::arg::disable::CacheDisableFlag;
|
use crate::cache::arg::disable::CacheDisableFlag;
|
||||||
|
@ -95,35 +99,37 @@ impl ListEnvelopesCommand {
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let filter = match self.query.map(|filter| filter.join(" ").parse()) {
|
let query = self
|
||||||
Some(Ok(filter)) => Some(filter),
|
.query
|
||||||
Some(Err(err)) => {
|
.map(|query| query.join(" ").parse::<SearchEmailsQuery>());
|
||||||
if let email::envelope::list::Error::ParseFilterError(errs, query) = &err {
|
|
||||||
errs.into_iter().for_each(|e| {
|
|
||||||
Report::build(ReportKind::Error, "query", e.span().start)
|
|
||||||
.with_message(e.to_string())
|
|
||||||
.with_label(
|
|
||||||
Label::new(("query", e.span().into_range()))
|
|
||||||
.with_message(e.reason().to_string())
|
|
||||||
.with_color(Color::Red),
|
|
||||||
)
|
|
||||||
.finish()
|
|
||||||
.eprint(("query", Source::from(&query)))
|
|
||||||
.unwrap()
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
Err(err)?;
|
let query = match query {
|
||||||
None
|
|
||||||
}
|
|
||||||
None => None,
|
None => None,
|
||||||
|
Some(Ok(query)) => Some(query),
|
||||||
|
Some(Err(main_err)) => {
|
||||||
|
let source = "query";
|
||||||
|
let email::search_query::Error::ParseError(errs, query) = &main_err;
|
||||||
|
for err in errs {
|
||||||
|
Report::build(ReportKind::Error, source, err.span().start)
|
||||||
|
.with_message(main_err.to_string())
|
||||||
|
.with_label(
|
||||||
|
Label::new((source, err.span().into_range()))
|
||||||
|
.with_message(err.reason().to_string())
|
||||||
|
.with_color(Color::Red),
|
||||||
|
)
|
||||||
|
.finish()
|
||||||
|
.eprint((source, Source::from(&query)))
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
exit(0)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let opts = ListEnvelopesOptions {
|
let opts = ListEnvelopesOptions {
|
||||||
page,
|
page,
|
||||||
page_size,
|
page_size,
|
||||||
filter,
|
query,
|
||||||
sort: Default::default(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let envelopes = backend.list_envelopes(folder, opts).await?;
|
let envelopes = backend.list_envelopes(folder, opts).await?;
|
||||||
|
|
Loading…
Reference in a new issue