use {
crate::{Ident, Span, database::chunk::ChunkId},
thiserror::Error,
};
#[derive(Debug, Error)]
pub enum LaburnumError {
#[error("Identifier must be 255 bytes or less, got {len} bytes at {span:?}")]
IdentTooLong { len: usize, span: Span },
#[error(
"Duplicate definition for partition key {partition_key} with sort key {sort_key} in chunks {chunks:?}"
)]
DuplicateDefinition {
partition_key: Ident,
sort_key: String,
chunks: Vec<ChunkId>,
},
#[error("Source not found")]
SourceNotFound,
#[error("File ID mismatch: expected {expected}, got {got}")]
FileIdMismatch { expected: u16, got: u16 },
#[error(
"Too many versions for file {file_id}: maximum 1024 versions allowed"
)]
TooManyVersions { file_id: u16 },
#[error("Too many files: maximum 65535 files allowed per package")]
TooManyFiles,
#[error("Filesystem error for {uri}: {error}")]
FileSystemError { uri: crate::Uri, error: String },
#[error("File not found")]
FileNotFound,
#[error("File content evicted")]
FileEvicted,
#[error("Invalid range")]
InvalidRange,
#[error("Task cancelled: source version no longer available")]
TaskCancelled,
#[error("Lock poisoned")]
LockPoisoned,
#[error("SpanCache is already complete")]
SpanCacheAlreadyComplete,
#[error("SpanCache not set")]
SpanCacheNotSet,
#[error("LSP version {lsp_version} already exists in cache")]
VersionAlreadyExists { lsp_version: i32 },
#[error("Cannot perform disk operation on open file: {operation}")]
FileOpenConflict { operation: &'static str },
#[error(
"Internal consistency error: file versions not found for file_id {file_id}"
)]
FileVersionsNotFound { file_id: u16 },
#[error("Version slot exhausted: all 1024 version slots are actively in use")]
VersionSlotExhausted,
}
pub trait ErrorReporter<P, T>: Send + Sync
where
P: crate::database::storage::Partitions,
T: crate::protocol::lsp::LanguageServer<P>,
{
fn report_diagnostics(&self, source_cache: &mut crate::SourceCache<P, T>);
fn report_no_diagnostics(&self, theme_files: &[url::Url]);
}