Skip to content

Commit

Permalink
Derive thiserror::Error for HexColorError
Browse files Browse the repository at this point in the history
  • Loading branch information
johanhelsing committed Aug 28, 2021
1 parent f6b42b8 commit 7b4e3a5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/bevy_render/src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use bevy_math::{Vec3, Vec4};
use bevy_reflect::{Reflect, ReflectDeserialize};
use serde::{Deserialize, Serialize};
use std::ops::{Add, AddAssign, Mul, MulAssign};
use thiserror::Error;

#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
#[reflect(PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -1070,10 +1071,12 @@ impl Bytes for Color {

impl_render_resource_bytes!(Color);

#[derive(Debug)]
#[derive(Debug, Error)]
pub enum HexColorError {
#[error("Unexpected length of hex string")]
Length,
Hex(hex::FromHexError),
#[error("Error parsing hex value")]
Hex(#[from] hex::FromHexError),
}

fn decode_rgb(data: &[u8]) -> Result<Color, HexColorError> {
Expand Down

0 comments on commit 7b4e3a5

Please sign in to comment.