1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use thiserror::Error;

pub use api::load_api;
pub use exporter::FactorioExporter;

mod api;
mod exporter;
mod internal;

#[derive(Error, Debug)]
pub enum FactorioExporterError {
    #[error("API definition file (runtime-api.json) not found")]
    ApiDefinitionNotFound(),
    #[error("I/O error")]
    IoError(#[from] std::io::Error),
    #[error("failed to parse JSON")]
    JsonParsingError(#[from] serde_json::Error),
    #[error("failed to parse YAML")]
    YamlParsingError(#[from] serde_yaml::Error),
    #[error("error while executing Factorio")]
    FactorioExecutionError { stdout: String, stderr: String },
}

pub type Result<T> = std::result::Result<T, FactorioExporterError>;