#[derive(Debug)]
pub enum Error {
NoActivePipeline,
NoActiveIndexBuffer,
IncompleteFramebuffer(u32),
InvalidIndexElementSize(usize),
InvalidIndexElementCount(usize),
InvalidBufferDataSize(usize),
MissingColorAttachment,
MissingDepthAttachment,
MissingAttachment,
AttachmentSizeMismatch,
AlphaBlendWithoutColor,
TextureLayoutMismatch,
UniformLayoutMismatch,
Internal(String),
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::NoActivePipeline => {
write!(f, "this operation requires an active pipeline")
}
Self::NoActiveIndexBuffer => {
write!(f, "this operation requires an active index buffer")
}
Self::MissingAttachment => {
write!(
f,
"render pass should have at least one render target specified"
)
}
Self::MissingColorAttachment => {
write!(f, "render pass color attachment is missing")
}
Self::MissingDepthAttachment => {
write!(f, "render pass depth attachment is missing")
}
Self::AttachmentSizeMismatch => {
write!(f, "render pass attachment size mismatch")
}
Self::AlphaBlendWithoutColor => {
write!(f, "alpha blend specified without color blend")
}
Self::TextureLayoutMismatch => {
write!(f, "texture binding doesn't match shader layout")
}
Self::UniformLayoutMismatch => {
write!(f, "uniform data doesn't match shader layout")
}
Self::IncompleteFramebuffer(status) => {
write!(f, "framebuffer is incomplete (status {status:x})")
}
Self::InvalidIndexElementSize(s) => {
write!(f, "index buffer element size `{s}` is invalid")
}
Self::InvalidIndexElementCount(s) => {
write!(f, "element count `{s}` is not within index buffer range")
}
Self::InvalidBufferDataSize(s) => {
write!(f, "buffer data size `{s}` is invalid")
}
Self::Internal(e) => {
write!(f, "{e}")
}
}
}
}
impl std::error::Error for Error {}