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

105 lines
2.2 KiB

  1. use std::io::Error as IoError;
  2. use glc::error::Error as GlcError;
  3. use glutin::{
  4. error::ExternalError as GlutinExternalError, ContextError as GlutinContextError,
  5. CreationError as GlutinCreationError,
  6. };
  7. use glyph_brush::ab_glyph::InvalidFont;
  8. use serde_json::Error as JsonError;
  9. use space_crush_common::{misc::VfsError, Error as CommonError};
  10. use thiserror::Error;
  11. #[derive(Debug, Error)]
  12. pub enum Error {
  13. #[error("IO Error: {0}")]
  14. IoError(IoError),
  15. #[error("JSON Error: {0}")]
  16. JsonError(JsonError),
  17. #[error("GLC Error: {0}")]
  18. GlcError(GlcError),
  19. #[error("glutin Context Error: {0}")]
  20. GlutinContextError(GlutinContextError),
  21. #[error("glutin Creation Error: {0}")]
  22. GlutinCreationError(GlutinCreationError),
  23. #[error("glutin External Error: {0}")]
  24. GlutinExternalError(GlutinExternalError),
  25. #[error("Invalid Font: {0}")]
  26. InvalidFont(InvalidFont),
  27. #[error("VFS Error: {0}")]
  28. VfsError(VfsError),
  29. #[error("{0}")]
  30. CommonError(CommonError),
  31. #[error("Resource is not registered: {0}!")]
  32. ResourceNotRegistered(&'static str),
  33. #[error("Unable to create OpenGL context!")]
  34. CreateContext,
  35. #[error("Font is not set!")]
  36. FontNotSet,
  37. }
  38. impl From<IoError> for Error {
  39. fn from(err: IoError) -> Self {
  40. Self::IoError(err)
  41. }
  42. }
  43. impl From<JsonError> for Error {
  44. fn from(err: JsonError) -> Self {
  45. Self::JsonError(err)
  46. }
  47. }
  48. impl From<GlcError> for Error {
  49. fn from(err: GlcError) -> Self {
  50. Self::GlcError(err)
  51. }
  52. }
  53. impl From<GlutinContextError> for Error {
  54. fn from(err: GlutinContextError) -> Self {
  55. Self::GlutinContextError(err)
  56. }
  57. }
  58. impl From<GlutinCreationError> for Error {
  59. fn from(err: GlutinCreationError) -> Self {
  60. Self::GlutinCreationError(err)
  61. }
  62. }
  63. impl From<GlutinExternalError> for Error {
  64. fn from(err: GlutinExternalError) -> Self {
  65. Self::GlutinExternalError(err)
  66. }
  67. }
  68. impl From<InvalidFont> for Error {
  69. fn from(err: InvalidFont) -> Self {
  70. Self::InvalidFont(err)
  71. }
  72. }
  73. impl From<VfsError> for Error {
  74. fn from(err: VfsError) -> Self {
  75. Self::VfsError(err)
  76. }
  77. }
  78. impl From<CommonError> for Error {
  79. fn from(err: CommonError) -> Self {
  80. Self::CommonError(err)
  81. }
  82. }