Skip to main content

NbError

Enum NbError 

Source
pub enum NbError {
Show 29 variants CommandFailed { command: String, stderr: String, exit_code: Option<i32>, }, ExecutableNotFound { path: String, }, NotFound { selector: String, }, Io { path: PathBuf, source: IoError, }, UnsupportedShowTarget { selector: String, actual_type: String, }, DuplicateTitleHeading { title: String, heading: String, }, ParseError { kind: ParseErrorKind, location: Range<usize>, }, InvalidFingerprint { reason: String, }, JsonParseError { source: String, }, ValidationError { reason: String, location: Option<Range<usize>>, }, UnsupportedDocumentFormat { extension: String, supported: Vec<String>, }, GateTimeout { gate: String, timeout_ms: u64, }, DirtyBaseline { guidance: String, }, PathCollision { path: String, plan_index: Option<u32>, }, PathIgnored { path: String, guidance: String, plan_index: Option<u32>, }, PlanValidation { kind: String, message: String, plan_index: Option<u32>, }, IndeterminateCommit { pre_revision: String, post_revision_observed: Option<String>, guidance: String, }, RecoveryRequired { pre_revision: String, post_revision_observed: Option<String>, status_observed: Option<String>, preserved_paths: Option<Vec<String>>, guidance: String, }, FingerprintMismatch { target: NoteTarget, guidance: String, }, AnchorMismatch { target: String, number: u32, guidance: String, }, OccurrenceMismatch { expected: u32, actual: u32, }, OverlappingEdits { indices: Vec<u32>, }, InvalidLineWindow { offset: u32, limit: u32, total_lines: u32, }, EmptySubstringPattern, FragmentedBody { fragment_count: u32, guidance: String, }, NonUtf8 { selector: String, path: String, kind: String, mime_hint: Option<String>, }, IndexLockTimeout { path: String, timeout_ms: u64, }, UnsupportedStructure { reason: String, }, WrongKind { expected: KindSet, actual: EntityKind, selector: String, path: String, },
}
Expand description

Errors raised by nb-api operations.

All variants are serializable so they can traverse MCP tool response envelopes without lossy string flattening. The std::error::Error implementation remains for ergonomic interop with code that uses ? and standard error reporting.

std::error::Error is implemented MANUALLY below rather than via thiserror::Error derive. The derive’s autodetect treats any field named source as a #[source] chain link and tries to convert it to dyn Error, which fails for fields of type String (e.g., JsonParseError { source: String } per the P1 specification). The manual impl preserves the field name and only sets a source-chain link for variants whose source field is itself an Error.

Variants§

§

CommandFailed

An nb subprocess invocation failed (non-zero exit, or spawning failed for a non-NotFound reason).

Fields

§command: String

The argument vector (joined) that was executed.

§stderr: String

Captured stderr (or stdout when stderr was empty).

§exit_code: Option<i32>

Process exit code, if the process started.

§

ExecutableNotFound

The nb executable could not be located on PATH (or in the resolved location) when a subprocess was spawned.

Fields

§path: String

The resolved path the spawn attempt targeted.

§

NotFound

nb reported that the requested selector was not found.

Fields

§selector: String

The selector that was not resolved.

§

Io

An I/O error occurred while accessing a notebook file or the on-disk notebook directory. The source field captures the original std::io::Error chain as a serializable snapshot (recursive IoError).

Fields

§path: PathBuf

Path that triggered the I/O error.

§source: IoError

Snapshot of the std::io::Error chain.

§

UnsupportedShowTarget

nb show was invoked on a selector whose type is not classified as text by nb itself (per the add-0-2-0-foundation public-API spec). Folders, archives, audio, video, image, and any other non-textual type reach this path. The classification delegates to nb show <selector> --type text so forward compatibility is automatic when nb adds new textual types. Probe failure (e.g., selector not found) does NOT route here; it falls through to the original CommandFailed error from the content-read path.

Fields

§selector: String
§actual_type: String
§

DuplicateTitleHeading

nb add was called with a title and content where the first nonblank line of content is an exact Markdown ATX H1 duplicating the title. The validation runs in the caller process before any subprocess invocation or notebook side effect (including resolve_notebook); the rejection happens entirely in-process. heading carries the exact detected source line (including the leading # and any surrounding whitespace) for actionable diagnostics. See add-0-2-0-foundation public-API specification.

Fields

§title: String
§heading: String
§

ParseError

A structural parse failure.

Fields

§location: Range<usize>
§

InvalidFingerprint

A fingerprint string failed structural validation (wrong prefix, wrong length, mixed case, etc.). reason carries a machine-readable category (e.g., "empty", "unknown_algorithm_prefix", "uppercase_hex").

Fields

§reason: String
§

JsonParseError

JSON deserialization failed when constructing a typed wrapper (e.g., crate::fingerprint::Fingerprint::from_json).

Fields

§source: String
§

ValidationError

A semantic validation error raised by an operation boundary (e.g., rejecting input that is structurally valid but semantically illegal). location is None when the failure is not byte-anchored.

Fields

§reason: String
§location: Option<Range<usize>>
§

UnsupportedDocumentFormat

Format-dispatch refusal (R3 revision).

parse(bytes, FromPath(path)) returned this error because the final filename matched one of the recognized-but- unsupported dotted suffixes (e.g., .org, .latex, .tex, .adoc, .asciidoc). Format dispatch precedes byte parsing, so no bytes were consumed and no parse-error location is meaningful — this is a contextual configuration error, not a parse failure.

extension carries the lowercase dotted suffix WITHOUT the leading dot (e.g., "org", "latex"). supported is the owned canonical list of supported extensions, populated at construction time from crate::SUPPORTED_DOCUMENT_EXTENSIONS. The owned Vec<String> shape is required for the derived Serialize / Deserialize round-trip contract on NbError.

Fields

§extension: String
§supported: Vec<String>
§

GateTimeout

Process-shared gate queue wait exceeded. Notebook was not mutated.

Fields

§gate: String
§timeout_ms: u64
§

DirtyBaseline

Transaction::commit refused because the notebook worktree/index is dirty.

Fields

§guidance: String
§

PathCollision

Plan-op path collision against snapshot or earlier plan ops.

Fields

§path: String
§plan_index: Option<u32>
§

PathIgnored

Plan targets or would leave durable state on a Git-ignored path in a way that cannot be represented in the single checkpoint (existing ignored entry mutation), or requires force-staging (reported only when force-stage is unavailable). Prefer rejecting existing-ignored mutators.

Fields

§path: String
§guidance: String
§plan_index: Option<u32>
§

PlanValidation

Validation/apply failure tied to a plan entry.

Fields

§kind: String
§message: String
§plan_index: Option<u32>
§

IndeterminateCommit

Commit completion is unknown (e.g. transport timeout after checkpoint may have started).

Fields

§pre_revision: String
§post_revision_observed: Option<String>
§guidance: String
§

RecoveryRequired

Cleanup after a known failed apply could not verify clean pre_revision.

Fields

§pre_revision: String
§post_revision_observed: Option<String>
§status_observed: Option<String>
§preserved_paths: Option<Vec<String>>
§guidance: String
§

FingerprintMismatch

Body fingerprint precondition failed.

Fields

§target: NoteTarget
§guidance: String
§

AnchorMismatch

Line number/anchor precondition failed.

Fields

§target: String
§number: u32
§guidance: String
§

OccurrenceMismatch

Substring expected_count did not match actual matches.

Fields

§expected: u32
§actual: u32
§

OverlappingEdits

Overlapping line edits in one batch.

Fields

§indices: Vec<u32>
§

InvalidLineWindow

Invalid show_note_lines window.

Fields

§offset: u32
§limit: u32
§total_lines: u32
§

EmptySubstringPattern

Empty substring pattern refused at enqueue/apply.

§

FragmentedBody

Contiguous-body-only op invoked on a multi-fragment document.

Fields

§fragment_count: u32
§guidance: String
§

NonUtf8

Structured text surface hit non-UTF-8 bytes in a text-classified file.

Non-textual notes keep using UnsupportedShowTarget; this variant covers the narrow non-UTF-8-but-text case. Use NbClient::read_note_source_bytes for raw access.

Fields

§selector: String
§path: String
§kind: String
§mime_hint: Option<String>
§

IndexLockTimeout

.nb-api-index.lock wait exceeded before any mutation.

Fields

§path: String
§timeout_ms: u64
§

UnsupportedStructure

Document structure is not supported for the requested op.

Fields

§reason: String
§

WrongKind

An operation was applied to an entity of the wrong kind: deleting a folder as a note, editing text of a non-textual file, or changing task state on a non-todo. Replaces string-matched ValidationError / UnsupportedStructure reasons with typed kinds. expected is the accepted-kinds set for the operation, actual the single observed kind.

Fields

§expected: KindSet
§actual: EntityKind
§selector: String
§path: String

Trait Implementations§

Source§

impl Clone for NbError

Source§

fn clone(&self) -> Self

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 NbError

Source§

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

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

impl<'de> Deserialize<'de> for NbError

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for NbError

Source§

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

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

impl Eq for NbError

Source§

impl Error for NbError

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 NbError

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for NbError

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for NbError

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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, !>

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more