refactor: improve error handle (#195)

This commit is contained in:
sigoden
2023-03-12 15:20:40 +08:00
committed by GitHub
parent c92e45f2da
commit 29a04c8d74
5 changed files with 17 additions and 25 deletions

View File

@@ -1,4 +1,4 @@
use anyhow::{anyhow, Result};
use anyhow::{anyhow, Context, Result};
use std::{
borrow::Cow,
path::Path,
@@ -8,7 +8,7 @@ use std::{
pub fn unix_now() -> Result<Duration> {
SystemTime::now()
.duration_since(UNIX_EPOCH)
.map_err(|err| anyhow!("Invalid system time, {err}"))
.with_context(|| "Invalid system time")
}
pub fn encode_uri(v: &str) -> String {