Skip to content

Remove thiserror from bevy_text #15762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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