diff --git a/Cargo.lock b/Cargo.lock index 05c9835..7ddadbd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,7 +86,7 @@ dependencies = [ "num-traits 0.2.19", "schemars", "serde", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -99,7 +99,7 @@ dependencies = [ "proc-macro2", "quote", "structmeta", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -314,7 +314,7 @@ checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -323,20 +323,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" -[[package]] -name = "err-derive" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c34a887c8df3ed90498c1c437ce21f211c8e27672921a8ffa293cb8d6d4caa9e" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "rustversion", - "syn 1.0.109", - "synstructure", -] - [[package]] name = "errno" version = "0.3.9" @@ -570,7 +556,7 @@ checksum = "8540b7d99a20166178b42a05776aef900cdbfec397f861dfc7819bf1d7760b3d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -685,7 +671,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -737,7 +723,7 @@ dependencies = [ "regex", "regex-syntax 0.8.4", "structmeta", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -791,7 +777,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -829,9 +815,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -928,12 +914,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "rustversion" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" - [[package]] name = "ryu" version = "1.0.18" @@ -970,7 +950,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -990,7 +970,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -1001,7 +981,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -1023,7 +1003,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -1065,7 +1045,7 @@ dependencies = [ "regex", "serde", "serde_derive", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -1077,7 +1057,7 @@ dependencies = [ "proc-macro2", "quote", "structmeta-derive", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -1088,7 +1068,7 @@ checksum = "152a0b65a590ff6c3da95cabe2353ee04e6167c896b28e3b14478c2636c922fc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -1104,27 +1084,15 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "unicode-xid", -] - [[package]] name = "tempfile" version = "3.10.1" @@ -1155,7 +1123,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -1166,7 +1134,7 @@ checksum = "5c89e72a01ed4c579669add59014b9a524d609c0c88c6a585ce37485879f6ffb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", "test-case-core", ] @@ -1179,7 +1147,6 @@ dependencies = [ "bitbuffer", "criterion", "enumflags2", - "err-derive", "fnv", "iai", "insta", @@ -1201,9 +1168,10 @@ dependencies = [ "serde_repr", "snap", "steamid-ng", - "syn 2.0.66", + "syn 2.0.90", "tempfile", "test-case", + "thiserror 2.0.4", "tracing", "tracing-subscriber", ] @@ -1214,7 +1182,16 @@ version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.61", +] + +[[package]] +name = "thiserror" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f49a1853cf82743e3b7950f77e0f4d622ca36cf4317cba00c767838bac8d490" +dependencies = [ + "thiserror-impl 2.0.4", ] [[package]] @@ -1225,7 +1202,18 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8381894bb3efe0c4acac3ded651301ceee58a15d47c2e34885ed1908ad667061" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", ] [[package]] @@ -1284,7 +1272,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -1332,12 +1320,6 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[package]] -name = "unicode-xid" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" - [[package]] name = "valuable" version = "0.1.0" @@ -1381,7 +1363,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", "wasm-bindgen-shared", ] @@ -1403,7 +1385,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/Cargo.toml b/Cargo.toml index e541238..4723924 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,7 +53,7 @@ snap = "1.1.1" serde = { version = "1.0.203", features = ["derive", "rc"] } serde_json = "1.0.117" serde_repr = "0.1.19" -err-derive = "0.3.1" +thiserror = "2.0.4" parse-display = "0.9.1" main_error = "0.1.2" jemallocator = { version = "0.5.4", optional = true } diff --git a/src/demo/parser/error.rs b/src/demo/parser/error.rs index f973085..0e97e7b 100644 --- a/src/demo/parser/error.rs +++ b/src/demo/parser/error.rs @@ -4,27 +4,24 @@ use crate::demo::message::packetentities::EntityId; use crate::demo::packet::datatable::{ClassId, SendTableName}; use crate::demo::sendprop::{SendPropIdentifier, SendPropValue}; use bitbuffer::BitError; -use err_derive::Error; use std::str::Utf8Error; use std::string::FromUtf8Error; +use thiserror::Error; /// Errors that can occur during parsing #[non_exhaustive] #[derive(Debug, Error)] pub enum ParseError { - #[error(display = "Error while reading bits from stream: {}", _0)] - ReadError(#[error(source, no_from)] BitError), - #[error(display = "Malformed utf8 while reading string")] - MalformedUTF8(#[error(source)] Utf8Error), - #[error(display = "Unexpected type of compressed data: {}", _0)] + #[error("Error while reading bits from stream: {0}")] + ReadError(#[source] BitError), + #[error("Malformed utf8 while reading string")] + MalformedUTF8(#[from] Utf8Error), + #[error("Unexpected type of compressed data: {0}")] UnexpectedCompressionType(String), + #[error("Error while decompressing SNAP compressed string table: {0}")] + SnapError(#[from] snap::Error), #[error( - display = "Error while decompressing SNAP compressed string table: {}", - _0 - )] - SnapError(#[error(source)] snap::Error), - #[error( - display = "Unexpected size after decompressing SNAP data, got {} bytes, expected {} bytes", + "Unexpected size after decompressing SNAP data, got {} bytes, expected {} bytes", size, expected )] @@ -34,78 +31,64 @@ pub enum ParseError { /// Actual decompressed size size: u32, }, - #[error(display = "Malformed demo file: {}", _0)] + #[error("Malformed demo file: {0}")] InvalidDemo(&'static str), - #[error(display = "Packet identifier is invalid: {}", _0)] + #[error("Packet identifier is invalid: {0}")] InvalidPacketType(u8), - #[error(display = "Message identifier is invalid: {}", _0)] + #[error("Message identifier is invalid: {0}")] InvalidMessageType(u8), - #[error(display = "Invalid SendProp type: {}", _0)] + #[error("Invalid SendProp type: {0}")] InvalidSendPropType(u8), - #[error(display = "Invalid SendProp: {}", _0)] - InvalidSendProp(#[error(source)] MalformedSendPropDefinitionError), - #[error( - display = "Unexpected amount of data left after parsing an object, {} bits remaining", - _0 - )] + #[error("Invalid SendProp: {0}")] + InvalidSendProp(#[from] MalformedSendPropDefinitionError), + #[error("Unexpected amount of data left after parsing an object, {0} bits remaining")] DataRemaining(usize), - #[error(display = "String table with index {} not found", _0)] + #[error("String table with index {0} not found")] StringTableNotFound(u8), - #[error(display = "A malformed game event was read: {}", _0)] - MalformedGameEvent(#[error(source)] GameEventError), + #[error("A malformed game event was read: {0}")] + MalformedGameEvent(#[from] GameEventError), #[error( - display = "A read game event doesn't contain the expected values, expected type {} for {} event, got type {}", - expected_type, - name, - found_type + "A read game event doesn't contain the expected values, expected type {expected_type} for {name} event, got type {found_type}" )] InvalidGameEvent { expected_type: GameEventValueType, name: &'static str, found_type: GameEventValueType, }, - #[error( - display = "Game event of type {} does not contain a {} value", - ty, - field - )] + #[error("Game event of type {ty} does not contain a {field} value")] MissingGameEventValue { ty: &'static str, field: String }, - #[error(display = "An entity with an unknown server class({}) was read", _0)] + #[error("An entity with an unknown server class({0}) was read")] UnknownServerClass(ClassId), - #[error(display = "Unknown send table: {}", _0)] + #[error("Unknown send table: {}", _0)] UnknownSendTable(SendTableName), - #[error( - display = "Property index out of bounds, got {} but only {} props exist", - _0, - _1 - )] + #[error("Property index out of bounds, got {index} but only {prop_count} props exist")] PropIndexOutOfBounds { index: i32, prop_count: usize, table: String, }, - #[error(display = "An attempt was made to update an unknown entity: {}", _0)] + #[error("An attempt was made to update an unknown entity: {0}")] UnknownEntity(EntityId), - #[error(display = "No sendprop definition found for property")] + #[error("No sendprop definition found for property")] UnknownDefinition(SendPropIdentifier), } #[non_exhaustive] #[derive(Debug, Error)] pub enum MalformedSendPropDefinitionError { - #[error(display = "Float property without defined size")] + #[error("Float property without defined size")] UnsizedFloat, - #[error(display = "Array property without defined size")] + #[error("Array property without defined size")] UnsizedArray, - #[error(display = "Array property without defined inner type")] + #[error("Array property without defined inner type")] UntypedArray, - #[error(display = "Property used that can't be read")] + #[error("Property used that can't be read")] InvalidPropType, - #[error(display = "Array contents can't have the 'ChangesOften' flag")] + #[error("Array contents can't have the 'ChangesOften' flag")] ArrayChangesOften, - #[error(display = "SendProp value out of range")] + #[error("SendProp value out of range")] OutOfRange, - #[error(display = "Wrong prop value type for definition")] + #[error("Wrong prop value type for definition")] WrongPropType { expected: &'static str, value: SendPropValue, @@ -115,11 +98,11 @@ pub enum MalformedSendPropDefinitionError { #[non_exhaustive] #[derive(Debug, Error)] pub enum GameEventError { - #[error(display = "Incorrect number of values")] + #[error("Incorrect number of values")] IncorrectValueCount, - #[error(display = "Event with 'none' value")] + #[error("Event with 'none' value")] NoneValue, - #[error(display = "Unknown type: {}", _0)] + #[error("Unknown type: {0}")] UnknownType(GameEventTypeId), }