diff --git a/contracts/okp4-cognitarium/src/error.rs b/contracts/okp4-cognitarium/src/error.rs index 6220b3aa..8012a946 100644 --- a/contracts/okp4-cognitarium/src/error.rs +++ b/contracts/okp4-cognitarium/src/error.rs @@ -1,4 +1,6 @@ use cosmwasm_std::{StdError, Uint128}; +use rio_turtle::TurtleError; +use rio_xml::RdfXmlError; use thiserror::Error; #[derive(Error, Debug, PartialEq)] @@ -6,6 +8,9 @@ pub enum ContractError { #[error("{0}")] Std(#[from] StdError), + #[error("{0}")] + ParseRDF(#[from] RDFParseError), + #[error("{0}")] Store(#[from] StoreError), @@ -16,6 +21,18 @@ pub enum ContractError { NotImplemented, } +impl From for ContractError { + fn from(value: RdfXmlError) -> Self { + ContractError::ParseRDF(RDFParseError::from(value)) + } +} + +impl From for ContractError { + fn from(value: TurtleError) -> Self { + ContractError::ParseRDF(RDFParseError::from(value)) + } +} + #[derive(Error, Debug, PartialEq)] pub enum StoreError { #[error("Maximum triples number exceeded: {0}")] @@ -39,3 +56,23 @@ pub enum StoreError { #[error("Maximum insert triple count exceeded: {0}")] MaxInsertDataTripleCount(Uint128), } + +#[derive(Error, Debug, PartialEq)] +pub enum RDFParseError { + #[error("Error parsing XML RDF: {0}")] + XML(String), + #[error("Error parsing Turtle RDF: {0}")] + Turtle(String), +} + +impl From for RDFParseError { + fn from(value: RdfXmlError) -> Self { + RDFParseError::XML(value.to_string()) + } +} + +impl From for RDFParseError { + fn from(value: TurtleError) -> Self { + RDFParseError::XML(value.to_string()) + } +} diff --git a/contracts/okp4-cognitarium/src/state/triples.rs b/contracts/okp4-cognitarium/src/state/triples.rs index 9e1d46e9..34851c3f 100644 --- a/contracts/okp4-cognitarium/src/state/triples.rs +++ b/contracts/okp4-cognitarium/src/state/triples.rs @@ -97,7 +97,7 @@ impl<'a> TryFrom> for Object { rio_api::model::Term::Literal(literal) => { Literal::try_from(literal).map(|l| Object::Literal(l)) } - _ => Err(StdError::generic_err("Not implemented")), + _ => Err(StdError::generic_err("RDF star syntax unsupported")), } } }