import strategy for error module (cont.)
This commit is contained in:
parent
e3fc06b019
commit
357f455ec0
1 changed files with 4 additions and 6 deletions
|
|
@ -4,8 +4,6 @@ use log::{debug, trace};
|
|||
use regex::Regex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::error;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct AliasID(String);
|
||||
|
||||
|
|
@ -52,9 +50,9 @@ impl fmt::Display for FileID {
|
|||
}
|
||||
|
||||
impl TryFrom<String> for FileID {
|
||||
type Error = error::Error;
|
||||
type Error = crate::Error;
|
||||
|
||||
fn try_from(value: String) -> error::Result<Self> {
|
||||
fn try_from(value: String) -> crate::Result<Self> {
|
||||
/// Pattern breakdown:
|
||||
/// - `^([^:/?#]+)://` – scheme (anything but `:/?#`) + `"://"`
|
||||
/// - `([^/?#]+)` – authority/host (anything but `/?#`)
|
||||
|
|
@ -83,7 +81,7 @@ impl TryFrom<String> for FileID {
|
|||
|
||||
Ok(result)
|
||||
} else {
|
||||
Err(error::Error::mismatch(
|
||||
Err(crate::Error::mismatch(
|
||||
"<proto>://<base>/api/v2/alias/upload/<share>/files/tus/<file>",
|
||||
value,
|
||||
))
|
||||
|
|
@ -143,7 +141,7 @@ mod tests {
|
|||
let err = FileID::try_from(bad.to_string()).expect_err("URL should not parse");
|
||||
// make sure it's the Mismatch variant, and that it contains the original input
|
||||
match err {
|
||||
error::Error::Mismatch { expected, actual } => {
|
||||
crate::Error::Mismatch { expected, actual } => {
|
||||
assert_eq!(
|
||||
expected, "<proto>://<base>/api/v2/alias/upload/<share>/files/tus/<file>",
|
||||
"Error should output expected format"
|
||||
|
|
|
|||
Loading…
Reference in a new issue