Skip to main content

ResolveError

Enum ResolveError 

Source
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.

Fields

§specifier: String

The specifier as written.

§

EscapesRoot

The specifier resolves outside the rules root.

Fields

§specifier: String

The specifier as written.

§

NotFound

Nothing exists at the specifier.

Fields

§specifier: String

The specifier as written.

§tried: String

The candidate paths that were tried.

§

Unreadable

The module exists but could not be read.

Fields

§path: String

The path that failed.

§detail: String

The underlying reason.

§

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.

Fields

§name: String

The built-in’s name, without the lanekeep/ prefix.

§

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.

Fields

§name: String

The built-in’s name, without the lanekeep/ prefix.

Trait Implementations§

Source§

impl Clone for ResolveError

Source§

fn clone(&self) -> ResolveError

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ResolveError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ResolveError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ResolveError

Source§

impl Error for ResolveError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for ResolveError

Source§

fn eq(&self, other: &ResolveError) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ResolveError

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ParallelSend for T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.