Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use consistent naming for error explanation field #9

Merged
merged 1 commit into from
Sep 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/error/logic_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use super::graphblas_error::{GraphBlasError, GraphBlasErrorType};
#[derive(Debug)]
pub struct LogicError {
error_type: LogicErrorType,
context: String,
explanation: String,
source: Option<LogicErrorSource>,
}

Expand All @@ -31,21 +31,21 @@ pub enum LogicErrorType {
impl LogicError {
pub fn new(
error_type: LogicErrorType,
context: String,
explanation: String,
source: Option<LogicErrorSource>,
) -> Self {
Self {
error_type,
context,
explanation,
source,
}
}

pub fn error_type(&self) -> LogicErrorType {
self.error_type.clone()
}
pub fn context(&self) -> String {
self.context.clone()
pub fn explanation(&self) -> String {
self.explanation.clone()
}
}

Expand All @@ -64,7 +64,7 @@ impl fmt::Display for LogicError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match &self.error_type {
// LogicErrorType::GraphBlas(_err) => writeln!(f, "Context:\n{}", &self.context)?,
_ => writeln!(f, "Context:\n{}", &self.context)?,
_ => writeln!(f, "Explanation:\n{}", &self.explanation)?,
};

match &self.source() {
Expand All @@ -79,7 +79,7 @@ impl From<GraphBlasError> for LogicError {
fn from(error: GraphBlasError) -> Self {
Self {
error_type: LogicErrorType::GraphBlas(error.error_type()),
context: String::new(),
explanation: String::new(),
source: Some(LogicErrorSource::GraphBlas(error)),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/error/other_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl OtherError {
pub fn error_type(&self) -> OtherErrorType {
self.error_type.clone()
}
pub fn context(&self) -> String {
pub fn explanation(&self) -> String {
self.explanation.clone()
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/error/system_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use super::graphblas_error::{GraphBlasError, GraphBlasErrorType};
#[derive(Debug)]
pub struct SystemError {
error_type: SystemErrorType,
context: String,
explanation: String,
source: Option<SystemErrorSource>,
}

Expand All @@ -32,21 +32,21 @@ pub enum SystemErrorType {
impl SystemError {
pub fn new(
error_type: SystemErrorType,
context: String,
explanation: String,
source: Option<SystemErrorSource>,
) -> Self {
Self {
error_type,
context,
explanation,
source,
}
}

pub fn error_type(&self) -> SystemErrorType {
self.error_type.clone()
}
pub fn context(&self) -> String {
self.context.clone()
pub fn explanation(&self) -> String {
self.explanation.clone()
}
}

Expand All @@ -65,7 +65,7 @@ impl error::Error for SystemError {
impl fmt::Display for SystemError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match &self.error_type {
_ => writeln!(f, "Context:\n{}", &self.context)?,
_ => writeln!(f, "Explanation:\n{}", &self.explanation)?,
};

match &self.source() {
Expand All @@ -80,7 +80,7 @@ impl From<GraphBlasError> for SystemError {
fn from(error: GraphBlasError) -> Self {
Self {
error_type: SystemErrorType::GraphBLAS(error.error_type()),
context: String::new(),
explanation: String::new(),
source: Some(SystemErrorSource::GraphBLAS(error)),
}
}
Expand Down