From 8fd3d54e48a6effb78a9112d580f9e99cf6717df Mon Sep 17 00:00:00 2001 From: Zachary Harrold Date: Thu, 10 Oct 2024 01:27:09 +1100 Subject: [PATCH] Remove `thiserror` from `bevy_text` (#15762) # Objective - Contributes to #15460 ## Solution - Removed `thiserror` from `bevy_text` --- crates/bevy_text/Cargo.toml | 6 +++++- crates/bevy_text/src/error.rs | 12 +++++++----- crates/bevy_text/src/font_loader.rs | 10 ++++------ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/crates/bevy_text/Cargo.toml b/crates/bevy_text/Cargo.toml index 5be451b84df12..57cea37b52a07 100644 --- a/crates/bevy_text/Cargo.toml +++ b/crates/bevy_text/Cargo.toml @@ -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" diff --git a/crates/bevy_text/src/error.rs b/crates/bevy_text/src/error.rs index ef9f7ea590deb..cd4d884d459b0 100644 --- a/crates/bevy_text/src/error.rs +++ b/crates/bevy_text/src/error.rs @@ -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), } diff --git a/crates/bevy_text/src/font_loader.rs b/crates/bevy_text/src/font_loader.rs index 9e0f2185a234e..fb491f49c2c93 100644 --- a/crates/bevy_text/src/font_loader.rs +++ b/crates/bevy_text/src/font_loader.rs @@ -1,6 +1,6 @@ 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) @@ -8,14 +8,12 @@ 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 {