ps_alloc/
error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use std::alloc::LayoutError;

use thiserror::Error;

#[derive(Debug, Error)]
pub enum AllocationError {
    #[error("An arithmetic error occured.")]
    ArithmeticError,
    #[error(transparent)]
    LayoutError(#[from] LayoutError),
    #[error("Process ran out of memory.")]
    OutOfMemory,
}

#[derive(Debug, Error)]
pub enum DeallocationError {
    #[error("This memory was already freed.")]
    DoubleFree,
    #[error("The pointer provided was not properly aligned.")]
    ImproperAlignment,
    #[error("Tried to free memory not allocated by this crate.")]
    InvalidAllocation,
    #[error(transparent)]
    LayoutError(#[from] LayoutError),
    #[error("Tried to free a null pointer.")]
    NullPtr,
}