| 1 | pub type Result<T> = napi::Result<T>; |
| 2 | |
| 3 | pub trait NapiErrorExt<T> { |
| 4 | /// Convert to a napi error using from_reason(err.to_string()) |
| 5 | fn default_error(self) -> Result<T>; |
| 6 | } |
| 7 | |
| 8 | impl<T> NapiErrorExt<T> for std::result::Result<T, lancedb::Error> { |
| 9 | fn default_error(self) -> Result<T> { |
| 10 | self.map_err(|err| napi::Error::from_reason(err.to_string())) |
| 11 | } |
| 12 | } |