-
Notifications
You must be signed in to change notification settings - Fork 540
Open
Labels
enhancementNew feature or requestNew feature or request
Milestone
Description
The current error types suffer from a few problems:
- It's hard to differentiate between user input issues and internal issues (for example, with schema errors.)
- For internal errors, we often wish we had a backtrace.
Design
For classifying errors, I propose a three tier system:
- Status code: the general type of error. This could be inspired by HTTP errors. For example,
400forBadRequest. - Title: a short static description of the error. For example,
"Table not found". - Description: a dynamic string containing details specific to the instance. For example: "Table 'foo' not found in database 'bar'."
In addition, should include:
- The version of Lance (to make this easy to see from error reports)
- An optional Backtrace or Location. We should design the constructor for internal errors to always prefer a Backtrace when available.
// To keep the size of Result<T> small, we use a Box<InnerError> to store the
// actual error. This way, the size of Result<T> is just a pointer.
pub struct Error(pub Box<InnerError>);
/// Lance's generic error.
///
/// The error aims to make it easy to determine error handling. Errors can be
/// classified at three levels:
///
/// * status_code: generic kind of error. We re-use HTTP status codes since
/// they are well known.
/// * title: a specific kind of error. For example, "Table not found."
/// * details: the details for an instance of the error.
pub struct InnerError {
/// An HTTP status code that best describes the error.
pub status_code: StatusCode,
/// A short description of the error. For example, "Table not found.".
///
/// This should not contain details of the instance of the error. Instead,
/// save that for `details`. This should be the same for all instances of
/// the same error, and thus is a static string.
pub title: &'static str,
/// A longer description of the error, including details specific to the
/// instance. For example, "Table 'foo' not found in database 'bar'.".
pub details: String,
/// The underlying cause of the error, if any.
pub cause: Option<BoxedError>,
/// The backtrace or location of the error.
pub backtrace: MaybeBacktrace,
/// Version of the Lance library
pub version: &'static LanceVersion
}
pub enum MaybeBacktrace {
Captured(Backtrace),
Location(&'static std::panic::Location<'static>),
None,
}Development
- Define new error type
- Provide conversion from existing error type to new error type
- Iteratively go through libraries replacing creation of old error type with new error type
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request