You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
938 B
Rust

use std::{
fmt::{Debug, Display, Formatter},
path::PathBuf,
};
4 years ago
#[derive(Debug)]
pub enum Error {
IOError(Box<dyn std::error::Error>),
4 years ago
InvalidObjectType(u32),
InvalidSectionName,
4 years ago
InvalidSectionData,
ParseError(Box<dyn std::error::Error>),
LinkingError(Trace),
}
// "backtrace" for error origin
#[derive(Debug)]
pub struct Trace {
origin: PathBuf,
offset: u64, // 0 indicates unknown/invalid
source_info: Option<Box<dyn SourceInfo>>,
}
pub trait SourceInfo: Debug + Display {
fn line(&self) -> u64;
// todo
4 years ago
}
impl From<std::io::Error> for Error {
fn from(err: std::io::Error) -> Self {
Self::IOError(Box::new(err))
4 years ago
}
}
impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "TODO!")
}
}
impl Display for Trace {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "TODO!")
}
}