@@ -4,7 +4,6 @@ pub use dicom_core::error::{CastValueError, InvalidValueReadError};
44use dicom_core:: Tag ;
55use dicom_encoding:: error:: { Error as EncodingError , TextEncodingError } ;
66use quick_error:: quick_error;
7- use std:: error:: Error as BaseError ;
87use std:: fmt;
98use std:: io;
109
@@ -17,89 +16,77 @@ quick_error! {
1716 pub enum Error {
1817 /// Not valid DICOM content, typically raised when checking the magic code.
1918 InvalidFormat {
20- description ( "Content is not DICOM or is corrupted" )
19+ display ( "Content is not DICOM or is corrupted" )
2120 }
2221 /// A required element in the meta group is missing
2322 MissingMetaElement ( name: & ' static str ) {
2423 display( "Missing required meta element `{}`" , name)
2524 }
2625 /// Raised when the obtained data element was not the one expected.
2726 UnexpectedTag ( tag: Tag ) {
28- description( "Unexpected DICOM element tag in current reading position" )
2927 display( "Unexpected DICOM tag {}" , tag)
3028 }
3129 InconsistentSequenceEnd ( eos: u64 , bytes_read: u64 ) {
32- description( "inconsistence sequence end position" )
3330 display( "already read {} bytes, but end of sequence is @ {} bytes" , bytes_read, eos)
3431 }
3532 /// Raised when the obtained length is inconsistent.
3633 UnexpectedDataValueLength {
37- description ( "Inconsistent data value length in data element" )
34+ display ( "Inconsistent data value length in data element" )
3835 }
3936 /// Raised when a read was illegally attempted.
4037 IllegalDataRead {
41- description ( "Illegal data value read" )
38+ display ( "Illegal data value read" )
4239 }
4340 /// Raised when the demanded transfer syntax is not supported.
4441 UnsupportedTransferSyntax {
45- description ( "Unsupported transfer syntax" )
42+ display ( "Unsupported transfer syntax" )
4643 }
4744 /// Raised when the required character set is not supported.
4845 UnsupportedCharacterSet {
49- description ( "Unsupported character set" )
46+ display ( "Unsupported character set" )
5047 }
5148 /// Raised when attempting to fetch an element by an unknown attribute name.
5249 NoSuchAttributeName {
53- description ( "No such attribute name" )
50+ display ( "No such attribute name" )
5451 }
5552 /// Raised when attempting to fetch an unexistent element.
5653 NoSuchDataElement {
57- description ( "No such data element" )
54+ display ( "No such data element" )
5855 }
5956 /// Raised when attempting to read pixel data out of bounds.
6057 PixelDataOutOfBounds {
61- description ( "Pixel data access index out of bounds" )
58+ display ( "Pixel data access index out of bounds" )
6259 }
6360 /// Raised when a data set parser couldn't fetch a value after a primitive
6461 /// data element's header.
6562 MissingElementValue {
66- description ( "Expected value after data element header, but was missing" )
63+ display ( "Expected value after data element header, but was missing" )
6764 }
6865 /// Raised while parsing a DICOM data set and found an unexpected
6966 /// element header or value.
7067 DataSetSyntax ( err: DataSetSyntaxError ) {
71- description( "Data set syntax error" )
7268 from( )
73- cause( err)
74- display( self_) -> ( "{}: {}" , self_. description( ) , err. description( ) )
69+ display( "Data set syntax error: {}" , err)
7570 }
7671 /// Error related to an invalid value read.
7772 ReadValue ( err: InvalidValueReadError ) {
78- description( "Invalid value read" )
7973 from( )
80- cause( err)
81- display( self_) -> ( "{}: {}" , self_. description( ) , err. description( ) )
74+ display( "Invalid value read: {}" , err)
8275 }
8376 /// Error related to a failed text encoding / decoding procedure.
8477 TextEncoding ( err: TextEncodingError ) {
85- description( "Failed text encoding/decoding" )
8678 from( )
87- cause( err)
88- display( self_) -> ( "{}: {}" , self_. description( ) , err. description( ) )
79+ display( "Failed text encoding/decoding: {}" , err)
8980 }
9081 /// A failed attempt to cast a value to an inappropriate format.
9182 CastValue ( err: CastValueError ) {
92- description( "Failed value cast" )
9383 from( )
94- cause( err)
95- display( self_) -> ( "{}: {}" , self_. description( ) , err. description( ) )
84+ display( "Failed value cast: {}" , err)
9685 }
9786 /// Other I/O errors.
9887 Io ( err: io:: Error ) {
99- description( "I/O error" )
10088 from( )
101- cause( err)
102- display( self_) -> ( "{}: {}" , self_. description( ) , err. description( ) )
89+ display( "I/O error: {}" , err)
10390 }
10491 }
10592}
@@ -137,10 +124,8 @@ pub enum DataSetSyntaxError {
137124impl fmt:: Display for DataSetSyntaxError {
138125 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
139126 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) ,
144129 }
145130 }
146131}
0 commit comments