Skip to main content

entdb/
error.rs

1/*
2 * Copyright 2026 EntDB Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17use crate::storage::page::PageId;
18use thiserror::Error;
19
20#[derive(Debug, Error)]
21pub enum EntDbError {
22    #[error("i/o error: {0}")]
23    Io(#[from] std::io::Error),
24
25    #[error("page {0} not found")]
26    PageNotFound(PageId),
27
28    #[error("buffer pool full: no evictable pages")]
29    BufferPoolFull,
30
31    #[error("invalid page data: {0}")]
32    InvalidPage(String),
33
34    #[error("page {0} is pinned")]
35    PagePinned(PageId),
36
37    #[error("page {0} already exists in buffer pool")]
38    PageAlreadyPresent(PageId),
39
40    #[error("corruption detected: {0}")]
41    Corruption(String),
42
43    #[error("wal error: {0}")]
44    Wal(String),
45
46    #[error("query error: {0}")]
47    Query(String),
48}
49
50pub type Result<T> = std::result::Result<T, EntDbError>;