@@ -25,72 +25,89 @@ enum DecoderState {
2525 Failed , //TODO put "self.internal_state = DecoderState::Failed;" everywhere an unresolvable error occurs
2626}
2727
28- #[ derive( Debug , thiserror:: Error ) ]
28+ #[ derive( Debug , derive_more:: Display , derive_more:: From ) ]
29+ #[ cfg_attr( feature = "std" , derive( derive_more:: Error ) ) ]
2930#[ non_exhaustive]
3031pub enum BlockHeaderReadError {
31- #[ error( "Error while reading the block header" ) ]
32- ReadError ( #[ from] io:: Error ) ,
33- #[ error( "Reserved block occured. This is considered corruption by the documentation" ) ]
32+ #[ display( fmt = "Error while reading the block header" ) ]
33+ #[ from]
34+ ReadError ( io:: Error ) ,
35+ #[ display( fmt = "Reserved block occured. This is considered corruption by the documentation" ) ]
3436 FoundReservedBlock ,
35- #[ error( "Error getting block type: {0}" ) ]
36- BlockTypeError ( #[ from] BlockTypeError ) ,
37- #[ error( "Error getting block content size: {0}" ) ]
38- BlockSizeError ( #[ from] BlockSizeError ) ,
37+ #[ display( fmt = "Error getting block type: {_0}" ) ]
38+ #[ from]
39+ BlockTypeError ( BlockTypeError ) ,
40+ #[ display( fmt = "Error getting block content size: {_0}" ) ]
41+ #[ from]
42+ BlockSizeError ( BlockSizeError ) ,
3943}
4044
41- #[ derive( Debug , thiserror:: Error ) ]
45+ #[ derive( Debug , derive_more:: Display ) ]
46+ #[ cfg_attr( feature = "std" , derive( derive_more:: Error ) ) ]
4247#[ non_exhaustive]
4348pub enum BlockTypeError {
44- #[ error (
45- "Invalid Blocktype number. Is: {num} Should be one of: 0, 1, 2, 3 (3 is reserved though"
49+ #[ display (
50+ fmt = "Invalid Blocktype number. Is: {num} Should be one of: 0, 1, 2, 3 (3 is reserved though"
4651 ) ]
4752 InvalidBlocktypeNumber { num : u8 } ,
4853}
4954
50- #[ derive( Debug , thiserror:: Error ) ]
55+ #[ derive( Debug , derive_more:: Display ) ]
56+ #[ cfg_attr( feature = "std" , derive( derive_more:: Error ) ) ]
5157#[ non_exhaustive]
5258pub enum BlockSizeError {
53- #[ error( "Blocksize was bigger than the absolute maximum {ABSOLUTE_MAXIMUM_BLOCK_SIZE} (128kb). Is: {size}" ) ]
59+ #[ display(
60+ fmt = "Blocksize was bigger than the absolute maximum {ABSOLUTE_MAXIMUM_BLOCK_SIZE} (128kb). Is: {size}"
61+ ) ]
5462 BlockSizeTooLarge { size : u32 } ,
5563}
5664
57- #[ derive( Debug , thiserror:: Error ) ]
65+ #[ derive( Debug , derive_more:: Display , derive_more:: From ) ]
66+ #[ cfg_attr( feature = "std" , derive( derive_more:: Error ) ) ]
5867#[ non_exhaustive]
5968pub enum DecompressBlockError {
60- #[ error( "Error while reading the block content: {0}" ) ]
61- BlockContentReadError ( #[ from] io:: Error ) ,
62- #[ error( "Malformed section header. Says literals would be this long: {expected_len} but there are only {remaining_bytes} bytes left" ) ]
69+ #[ display( fmt = "Error while reading the block content: {_0}" ) ]
70+ #[ from]
71+ BlockContentReadError ( io:: Error ) ,
72+ #[ display(
73+ fmt = "Malformed section header. Says literals would be this long: {expected_len} but there are only {remaining_bytes} bytes left"
74+ ) ]
6375 MalformedSectionHeader {
6476 expected_len : usize ,
6577 remaining_bytes : usize ,
6678 } ,
67- #[ error( transparent) ]
68- DecompressLiteralsError ( #[ from] DecompressLiteralsError ) ,
69- #[ error( transparent) ]
70- LiteralsSectionParseError ( #[ from] LiteralsSectionParseError ) ,
71- #[ error( transparent) ]
72- SequencesHeaderParseError ( #[ from] SequencesHeaderParseError ) ,
73- #[ error( transparent) ]
74- DecodeSequenceError ( #[ from] DecodeSequenceError ) ,
75- #[ error( transparent) ]
76- ExecuteSequencesError ( #[ from] ExecuteSequencesError ) ,
79+ #[ display( fmt = "{_0:?}" ) ]
80+ #[ from]
81+ DecompressLiteralsError ( DecompressLiteralsError ) ,
82+ #[ display( fmt = "{_0:?}" ) ]
83+ #[ from]
84+ LiteralsSectionParseError ( LiteralsSectionParseError ) ,
85+ #[ display( fmt = "{_0:?}" ) ]
86+ #[ from]
87+ SequencesHeaderParseError ( SequencesHeaderParseError ) ,
88+ #[ display( fmt = "{_0:?}" ) ]
89+ #[ from]
90+ DecodeSequenceError ( DecodeSequenceError ) ,
91+ #[ display( fmt = "{_0:?}" ) ]
92+ #[ from]
93+ ExecuteSequencesError ( ExecuteSequencesError ) ,
7794}
7895
79- #[ derive( Debug , thiserror:: Error ) ]
96+ #[ derive( Debug , derive_more:: Display , derive_more:: From ) ]
97+ #[ cfg_attr( feature = "std" , derive( derive_more:: Error ) ) ]
8098#[ non_exhaustive]
8199pub enum DecodeBlockContentError {
82- #[ error ( "Can't decode next block if failed along the way. Results will be nonsense" ) ]
100+ #[ display ( fmt = "Can't decode next block if failed along the way. Results will be nonsense" ) ]
83101 DecoderStateIsFailed ,
84- #[ error( "Cant decode next block body, while expecting to decode the header of the previous block. Results will be nonsense" ) ]
102+ #[ display(
103+ fmt = "Cant decode next block body, while expecting to decode the header of the previous block. Results will be nonsense"
104+ ) ]
85105 ExpectedHeaderOfPreviousBlock ,
86- #[ error( "Error while reading bytes for {step}: {source}" ) ]
87- ReadError {
88- step : BlockType ,
89- #[ source]
90- source : io:: Error ,
91- } ,
92- #[ error( transparent) ]
93- DecompressBlockError ( #[ from] DecompressBlockError ) ,
106+ #[ display( fmt = "Error while reading bytes for {step}: {source}" ) ]
107+ ReadError { step : BlockType , source : io:: Error } ,
108+ #[ display( fmt = "{_0:?}" ) ]
109+ #[ from]
110+ DecompressBlockError ( DecompressBlockError ) ,
94111}
95112
96113pub fn new ( ) -> BlockDecoder {
0 commit comments