-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Nico Wagner <[email protected]>
- Loading branch information
Showing
13 changed files
with
2,385 additions
and
2,241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,8 @@ | ||
use thiserror::Error; | ||
use crate::primitives::ParsePicaError; | ||
|
||
// macro_rules! bail { | ||
// ($($tt:tt)*) => {{ | ||
// return Err(crate::error::Error::Other(format!($($tt)*))) | ||
// }}; | ||
// } | ||
|
||
// pub(crate) use bail; | ||
|
||
/// An error that can occur in this library. | ||
#[derive(Debug, Error)] | ||
/// An error that can occur in this crate. | ||
#[derive(Debug, thiserror::Error)] | ||
pub enum Error { | ||
#[error(transparent)] | ||
ParsePica(ParsePicaError), | ||
|
||
#[error("{0}")] | ||
Other(String), | ||
} | ||
|
||
/// An error that can occur when parsing PICA+ records. | ||
#[derive(Debug, Error)] | ||
pub enum ParsePicaError { | ||
#[error("'{0}' is not a valid subfield code.")] | ||
SubfieldCode(char), | ||
#[error("'{0}' is not a valid subfield value.")] | ||
SubfieldValue(String), | ||
#[error("'{0}' is not a valid subfield.")] | ||
Subfield(String), | ||
#[error("'{0}' is not a valid tag.")] | ||
Tag(String), | ||
#[error("'{0}' is not a valid occurrence.")] | ||
Occurrence(String), | ||
#[error("'{0}' is not a valid field.")] | ||
Field(String), | ||
#[error("'{0}' is not a valid record.")] | ||
Record(String), | ||
#[error("'{0}' is not a valid string record.")] | ||
StringRecord(String), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//! General-use types and traits from this crate. | ||
//! | ||
//! This module contains the most used types, type aliases, traits, | ||
//! functions and macros for glob import. | ||
//! | ||
//! # Example | ||
//! | ||
//! ```rust | ||
//! use pica_record::prelude::*; | ||
//! | ||
//! let record = ByteRecord::from_bytes(b"002@ \x1f0Olfo\x1e\n")?; | ||
//! assert!(record.validate().is_ok()); | ||
//! | ||
//! # Ok::<(), Box<dyn std::error::Error>>(()) | ||
//! ``` | ||
|
||
pub use crate::{ByteRecord, Error, StringRecord}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use thiserror::Error; | ||
|
||
/// An error that can occur when parsing PICA+ records. | ||
#[derive(Debug, Error)] | ||
#[error("{0}")] | ||
pub struct ParsePicaError(pub(crate) String); |
Oops, something went wrong.