oxc/crates/oxc_sourcemap/src/error.rs
underfin b199cb89a2
feat: add oxc sourcemap crate (#2825)
The sourcemap implement port from
[rust-sourcemap](https://github.com/getsentry/rust-sourcemap), but has
some different with it.

- Encode sourcemap at parallel, including quote `sourceContent` and
encode token to `vlq` mappings.
- Avoid `Sourcemap` some methods overhead, like `SourceMap::tokens()`
caused extra overhead at common cases. Here using `SourceViewToken` to
instead of it.
2024-03-28 19:36:38 +08:00

26 lines
795 B
Rust

#[derive(Debug)]
pub enum Error {
/// a VLQ string was malformed and data was left over
VlqLeftover,
/// a VLQ string was empty and no values could be decoded.
VlqNoValues,
/// The input encoded a number that didn't fit into i64.
VlqOverflow,
/// `serde_json` parsing failure
BadJson(serde_json::Error),
/// a mapping segment had an unsupported size
BadSegmentSize(u32),
/// a reference to a non existing source was encountered
BadSourceReference(u32),
/// a reference to a non existing name was encountered
BadNameReference(u32),
}
/// The result of decoding.
pub type Result<T> = std::result::Result<T, Error>;
impl From<serde_json::Error> for Error {
fn from(err: serde_json::Error) -> Error {
Error::BadJson(err)
}
}