@@ -4,7 +4,6 @@ pub use dicom_core::error::{CastValueError, InvalidValueReadError};
4
4
use dicom_core:: Tag ;
5
5
use dicom_encoding:: error:: { Error as EncodingError , TextEncodingError } ;
6
6
use quick_error:: quick_error;
7
- use std:: error:: Error as BaseError ;
8
7
use std:: fmt;
9
8
use std:: io;
10
9
@@ -17,89 +16,77 @@ quick_error! {
17
16
pub enum Error {
18
17
/// Not valid DICOM content, typically raised when checking the magic code.
19
18
InvalidFormat {
20
- description ( "Content is not DICOM or is corrupted" )
19
+ display ( "Content is not DICOM or is corrupted" )
21
20
}
22
21
/// A required element in the meta group is missing
23
22
MissingMetaElement ( name: & ' static str ) {
24
23
display( "Missing required meta element `{}`" , name)
25
24
}
26
25
/// Raised when the obtained data element was not the one expected.
27
26
UnexpectedTag ( tag: Tag ) {
28
- description( "Unexpected DICOM element tag in current reading position" )
29
27
display( "Unexpected DICOM tag {}" , tag)
30
28
}
31
29
InconsistentSequenceEnd ( eos: u64 , bytes_read: u64 ) {
32
- description( "inconsistence sequence end position" )
33
30
display( "already read {} bytes, but end of sequence is @ {} bytes" , bytes_read, eos)
34
31
}
35
32
/// Raised when the obtained length is inconsistent.
36
33
UnexpectedDataValueLength {
37
- description ( "Inconsistent data value length in data element" )
34
+ display ( "Inconsistent data value length in data element" )
38
35
}
39
36
/// Raised when a read was illegally attempted.
40
37
IllegalDataRead {
41
- description ( "Illegal data value read" )
38
+ display ( "Illegal data value read" )
42
39
}
43
40
/// Raised when the demanded transfer syntax is not supported.
44
41
UnsupportedTransferSyntax {
45
- description ( "Unsupported transfer syntax" )
42
+ display ( "Unsupported transfer syntax" )
46
43
}
47
44
/// Raised when the required character set is not supported.
48
45
UnsupportedCharacterSet {
49
- description ( "Unsupported character set" )
46
+ display ( "Unsupported character set" )
50
47
}
51
48
/// Raised when attempting to fetch an element by an unknown attribute name.
52
49
NoSuchAttributeName {
53
- description ( "No such attribute name" )
50
+ display ( "No such attribute name" )
54
51
}
55
52
/// Raised when attempting to fetch an unexistent element.
56
53
NoSuchDataElement {
57
- description ( "No such data element" )
54
+ display ( "No such data element" )
58
55
}
59
56
/// Raised when attempting to read pixel data out of bounds.
60
57
PixelDataOutOfBounds {
61
- description ( "Pixel data access index out of bounds" )
58
+ display ( "Pixel data access index out of bounds" )
62
59
}
63
60
/// Raised when a data set parser couldn't fetch a value after a primitive
64
61
/// data element's header.
65
62
MissingElementValue {
66
- description ( "Expected value after data element header, but was missing" )
63
+ display ( "Expected value after data element header, but was missing" )
67
64
}
68
65
/// Raised while parsing a DICOM data set and found an unexpected
69
66
/// element header or value.
70
67
DataSetSyntax ( err: DataSetSyntaxError ) {
71
- description( "Data set syntax error" )
72
68
from( )
73
- cause( err)
74
- display( self_) -> ( "{}: {}" , self_. description( ) , err. description( ) )
69
+ display( "Data set syntax error: {}" , err)
75
70
}
76
71
/// Error related to an invalid value read.
77
72
ReadValue ( err: InvalidValueReadError ) {
78
- description( "Invalid value read" )
79
73
from( )
80
- cause( err)
81
- display( self_) -> ( "{}: {}" , self_. description( ) , err. description( ) )
74
+ display( "Invalid value read: {}" , err)
82
75
}
83
76
/// Error related to a failed text encoding / decoding procedure.
84
77
TextEncoding ( err: TextEncodingError ) {
85
- description( "Failed text encoding/decoding" )
86
78
from( )
87
- cause( err)
88
- display( self_) -> ( "{}: {}" , self_. description( ) , err. description( ) )
79
+ display( "Failed text encoding/decoding: {}" , err)
89
80
}
90
81
/// A failed attempt to cast a value to an inappropriate format.
91
82
CastValue ( err: CastValueError ) {
92
- description( "Failed value cast" )
93
83
from( )
94
- cause( err)
95
- display( self_) -> ( "{}: {}" , self_. description( ) , err. description( ) )
84
+ display( "Failed value cast: {}" , err)
96
85
}
97
86
/// Other I/O errors.
98
87
Io ( err: io:: Error ) {
99
- description( "I/O error" )
100
88
from( )
101
- cause( err)
102
- display( self_) -> ( "{}: {}" , self_. description( ) , err. description( ) )
89
+ display( "I/O error: {}" , err)
103
90
}
104
91
}
105
92
}
@@ -137,10 +124,8 @@ pub enum DataSetSyntaxError {
137
124
impl fmt:: Display for DataSetSyntaxError {
138
125
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
139
126
match self {
140
- DataSetSyntaxError :: PrematureEnd => f. write_str ( self . description ( ) ) ,
141
- DataSetSyntaxError :: UnexpectedToken ( ref token) => {
142
- write ! ( f, "{} {}" , self . description( ) , token)
143
- }
127
+ DataSetSyntaxError :: PrematureEnd => write ! ( f, "{}" , self ) ,
128
+ DataSetSyntaxError :: UnexpectedToken ( ref token) => write ! ( f, "{} {}" , self , token) ,
144
129
}
145
130
}
146
131
}
0 commit comments