path_planning/
error.rs

1/* Copyright (C) 2020 Dylan Staatz - All Rights Reserved. */
2
3pub type Result<T> = std::result::Result<T, Error>;
4
5#[derive(thiserror::Error, Debug)]
6pub enum Error {
7  #[error("Invalid Parameter: {0}")]
8  InvalidParamError(#[from] InvalidParamError),
9  #[error("I/O Error: {0}")]
10  IoError(#[from] std::io::Error),
11  #[error("RON Error: {0}")]
12  RonError(#[from] ron::Error),
13  #[error("Bincode Error: {0}")]
14  BincodeError(#[from] bincode::Error),
15  #[error("{0}")]
16  RunBuildingError(#[from] RunBuildingError),
17  #[error("{0}")]
18  IndexOutOfBounds(#[from] IndexOutOfBounds),
19  #[error("{0}")]
20  StatesNotRecorded(#[from] StatesNotRecorded),
21  #[error("{0}")]
22  RandError(#[from] rand::Error),
23  #[error("Failed convex hull operation")]
24  ConvexHullError,
25  #[error("{0}")]
26  TimeError(#[from] time::Error),
27  #[error("{0}")]
28  CtrlcError(#[from] ctrlc::Error),
29  #[error("{0}")]
30  KdTreeError(#[from] kdtree::ErrorKind),
31  #[error("Strip Prefix Error: {0}")]
32  StripPrefixError(#[from] std::path::StripPrefixError),
33}
34
35#[derive(thiserror::Error, Debug)]
36#[error("Index out of bounds")]
37pub struct IndexOutOfBounds;
38
39#[derive(thiserror::Error, Debug)]
40#[error("States were not recorded, set keep_in_memory to true or give output directory for states to be saved")]
41pub struct StatesNotRecorded;
42
43#[derive(thiserror::Error, Debug)]
44#[error("\"{parameter_name}\" was set to \"{parameter_value}\"")]
45pub struct InvalidParamError {
46  pub parameter_name: &'static str,
47  pub parameter_value: String,
48}
49
50#[derive(thiserror::Error, Debug)]
51pub enum RunBuildingError {
52  #[error("Must set parameter_file in builder")]
53  ParamsFileNotSet,
54}