forma icon indicating copy to clipboard operation
forma copied to clipboard

[proposal] Errors organized by phase

Open bluemoon opened this issue 4 years ago • 4 comments

Which of these make more sense?

/// Forma error type.
#[derive(Debug)]
pub enum FormaError {
  InputErrorType1,
  InputErrorType2,
  TransformationErrorType1,
  TransformationErrorType2,
  OutputErrorType1,
  OutputErrorType2
}

or:

#[derive(Debug)]
pub enum InputError {
  Something1,
  Something2
}

#[derive(Debug)]
pub enum FormaError {
  Input(InputError),
  Transformation(TransformationError),
  Output(OutputError)
}

bluemoon avatar May 11 '20 01:05 bluemoon

That's a good question. Would the second example be named like FormaInputError? It does seem like having separate types at different application boundaries could be nice.

maxcountryman avatar May 11 '20 13:05 maxcountryman

Also maybe these should actually be FormatError, etc?

maxcountryman avatar May 11 '20 13:05 maxcountryman

what do you mean by FormatError?

bluemoon avatar May 11 '20 17:05 bluemoon

I guess the real question is: is there a reason need to programmatically decide what category the error falls into e.g. if the input fails will the caller want to be able to match on the type of error to do something about it. If the caller needs to be able to tell that its a user input issue (say a SQL formatting website) then we will want a way to group these errors. Otherwise it doesn't really matter.

bluemoon avatar May 11 '20 17:05 bluemoon