Skip to content

Commit

Permalink
Remove thiserror from bevy_text (#15762)
Browse files Browse the repository at this point in the history
# Objective

- Contributes to #15460

## Solution

- Removed `thiserror` from `bevy_text`
  • Loading branch information
bushrat011899 authored Oct 9, 2024
1 parent 8718adc commit 8fd3d54
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
6 changes: 5 additions & 1 deletion crates/bevy_text/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ bevy_utils = { path = "../bevy_utils", version = "0.15.0-dev" }

# other
cosmic-text = { version = "0.12", features = ["shape-run-cache"] }
thiserror = "1.0"
derive_more = { version = "1", default-features = false, features = [
"error",
"from",
"display",
] }
serde = { version = "1", features = ["derive"] }
unicode-bidi = "0.3.13"
sys-locale = "0.3.0"
Expand Down
12 changes: 7 additions & 5 deletions crates/bevy_text/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
use cosmic_text::CacheKey;
use thiserror::Error;
use derive_more::derive::{Display, Error};

#[derive(Debug, PartialEq, Eq, Error)]
#[derive(Debug, PartialEq, Eq, Error, Display)]
/// Errors related to the textsystem
pub enum TextError {
/// Font was not found, this could be that the font has not yet been loaded, or
/// that the font failed to load for some other reason
#[error("font not found")]
#[display("font not found")]
NoSuchFont,
/// Failed to add glyph to a newly created atlas for some reason
#[error("failed to add glyph to newly-created atlas {0:?}")]
#[display("failed to add glyph to newly-created atlas {_0:?}")]
#[error(ignore)]
FailedToAddGlyph(u16),
/// Failed to get scaled glyph image for cache key
#[error("failed to get scaled glyph image for cache key: {0:?}")]
#[display("failed to get scaled glyph image for cache key: {_0:?}")]
#[error(ignore)]
FailedToGetGlyphImage(CacheKey),
}
10 changes: 4 additions & 6 deletions crates/bevy_text/src/font_loader.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
use crate::Font;
use bevy_asset::{io::Reader, AssetLoader, LoadContext};
use thiserror::Error;
use derive_more::derive::{Display, Error, From};

#[derive(Default)]
/// An [`AssetLoader`] for [`Font`]s, for use by the [`AssetServer`](bevy_asset::AssetServer)
pub struct FontLoader;

/// Possible errors that can be produced by [`FontLoader`]
#[non_exhaustive]
#[derive(Debug, Error)]
#[derive(Debug, Error, Display, From)]
pub enum FontLoaderError {
/// The contents that could not be parsed
#[error(transparent)]
Content(#[from] cosmic_text::ttf_parser::FaceParsingError),
Content(cosmic_text::ttf_parser::FaceParsingError),
/// An [IO](std::io) Error
#[error(transparent)]
Io(#[from] std::io::Error),
Io(std::io::Error),
}

impl AssetLoader for FontLoader {
Expand Down

0 comments on commit 8fd3d54

Please sign in to comment.