pub enum ResolveError {
BareSpecifier {
specifier: String,
},
EscapesRoot {
specifier: String,
},
NotFound {
specifier: String,
tried: String,
},
Unreadable {
path: String,
detail: String,
},
NotAModule {
name: String,
},
ComponentHostMissing {
name: String,
},
}Expand description
Why a module specifier could not be resolved.
Variants§
BareSpecifier
A bare specifier, which would be an npm package.
EscapesRoot
The specifier resolves outside the rules root.
NotFound
Nothing exists at the specifier.
Fields
Unreadable
The module exists but could not be read.
NotAModule
The specifier names a built-in that ships as a component rather than as a module.
Its own variant rather than a ResolveError::NotFound with a different string,
because the two are different facts and only one of them is the user’s mistake. A
built-in that is not there is a typo; a built-in that is a component is spelled
correctly and simply cannot be imported, and telling a reader to check their spelling
would send them looking for something that is not wrong.
One line, carrying both the fact and the remedy, and that is not a style choice.
QuickJS truncates a thrown error at 255 bytes, and a resolution failure reaches the user
as Error resolving module '<specifier>' from '<absolute path>': <this> — 35 bytes of
framing plus the specifier plus the project’s own path before this message starts. So
a second line is not a place to put anything: it is the first thing a real path spends
the budget on.
A two-line version of this shipped and was wrong in exactly that way. It front-loaded
the fact and put “name it in a lanekeep.json” second, which survived only for a config
path of 47 characters or fewer — so every user deep enough in a monorepo to have the
problem was told they had it and not what to do. There is no in-format escape either:
packages/lanekeep/index.d.ts types rules as Rule[], so a .config.ts cannot name
a rule by string. Converting to JSON is the only route, and that was the sentence being
cut.
The specifier is repeated here even though the framing already carries it, because this is a public error type and a sibling variant read alone names its subject. It costs the budget twice over, which is why the rest is as short as it is.
the_refusal_survives_quickjs_beside_a_long_path is what holds the arithmetic. See
AGENTS.md.
ComponentHostMissing
The specifier names a built-in that is declared as a component, but the component’s host is missing from the built-in table.
Its own variant rather than a ResolveError::NotFound with a different string,
because the two are different facts and only one of them is the user’s mistake. A
built-in that is not there is a typo; a built-in whose component row is broken is a
lanekeep bug, and telling a reader to check their spelling would send them looking for
something that is not wrong.
One line, carrying both the fact and the remedy, on the same terms as
ResolveError::NotAModule. QuickJS truncates a thrown error at 255 bytes, so the
message is budgeted the same way — see MAX_COMPONENT_NAME and
the_broken_row_refusal_survives_quickjs_beside_a_long_path.
Trait Implementations§
Source§impl Clone for ResolveError
impl Clone for ResolveError
Source§fn clone(&self) -> ResolveError
fn clone(&self) -> ResolveError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ResolveError
impl Debug for ResolveError
Source§impl Display for ResolveError
impl Display for ResolveError
impl Eq for ResolveError
Source§impl Error for ResolveError
impl Error for ResolveError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl PartialEq for ResolveError
impl PartialEq for ResolveError
impl StructuralPartialEq for ResolveError
Auto Trait Implementations§
impl Freeze for ResolveError
impl RefUnwindSafe for ResolveError
impl Send for ResolveError
impl Sync for ResolveError
impl Unpin for ResolveError
impl UnsafeUnpin for ResolveError
impl UnwindSafe for ResolveError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.