Move error definition
This commit is contained in:
parent
bba2d8e3d7
commit
6b8c7c40fa
@ -10,7 +10,7 @@ use std::fmt;
|
||||
#[cfg(test)]
|
||||
use mockall::automock;
|
||||
|
||||
use crate::core::collection::Collection;
|
||||
use crate::core::collection::{self, Collection};
|
||||
|
||||
/// Trait for interacting with the database.
|
||||
#[cfg_attr(test, automock)]
|
||||
@ -61,6 +61,14 @@ impl From<std::io::Error> for LoadError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<collection::Error> for LoadError {
|
||||
fn from(err: collection::Error) -> Self {
|
||||
match err {
|
||||
collection::Error::UrlError(e) => LoadError::SerDeError(e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Error type for database calls.
|
||||
#[derive(Debug)]
|
||||
pub enum SaveError {
|
||||
@ -111,6 +119,10 @@ mod tests {
|
||||
assert!(!io_err.to_string().is_empty());
|
||||
assert!(!format!("{:?}", io_err).is_empty());
|
||||
|
||||
let col_err: LoadError = collection::Error::UrlError(String::from("get rekt")).into();
|
||||
assert!(!col_err.to_string().is_empty());
|
||||
assert!(!format!("{:?}", col_err).is_empty());
|
||||
|
||||
let io_err: SaveError = io::Error::new(io::ErrorKind::Interrupted, "error").into();
|
||||
assert!(!io_err.to_string().is_empty());
|
||||
assert!(!format!("{:?}", io_err).is_empty());
|
||||
|
@ -3,10 +3,7 @@ use std::collections::HashMap;
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{
|
||||
collection::{
|
||||
self,
|
||||
artist::{ArtistId, MusicBrainz},
|
||||
},
|
||||
collection::artist::{ArtistId, MusicBrainz},
|
||||
core::{
|
||||
collection::{artist::Artist, Collection},
|
||||
database::{serde::Database, LoadError},
|
||||
@ -49,25 +46,3 @@ impl TryFrom<DeserializeArtist> for Artist {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl From<collection::Error> for LoadError {
|
||||
fn from(err: collection::Error) -> Self {
|
||||
match err {
|
||||
collection::Error::UrlError(e) => LoadError::SerDeError(e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn errors() {
|
||||
let col_err: LoadError = collection::Error::UrlError(String::from("get rekt")).into();
|
||||
|
||||
assert!(!col_err.to_string().is_empty());
|
||||
|
||||
assert!(!format!("{:?}", col_err).is_empty());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user