Skip to content

Commit 38be8d5

Browse files
committed
Remove use of deprecated Error::description
Error::description is fully deprecated now. See: rust-lang/rust#66919
1 parent 0e016f5 commit 38be8d5

File tree

9 files changed

+61
-130
lines changed

9 files changed

+61
-130
lines changed

core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ repository = "Enet4/dicom-rs"
1616
[dependencies]
1717
chrono = "0.4.6"
1818
itertools = "0.8.0"
19-
quick-error = "1.2.2"
19+
quick-error = "1.2.3"
2020
smallvec = "1.0.0"

core/src/error.rs

Lines changed: 16 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
use crate::value::ValueType;
33
use crate::Tag;
44
use quick_error::quick_error;
5-
use std::error::Error as BaseError;
65
use std::fmt;
76
use std::num::{ParseFloatError, ParseIntError};
87
use std::result;
@@ -13,26 +12,21 @@ quick_error! {
1312
pub enum Error {
1413
/// Raised when the obtained data element was not the one expected.
1514
UnexpectedTag(tag: Tag) {
16-
description("Unexpected DICOM element tag in current reading position")
1715
display("Unexpected DICOM tag {}", tag)
1816
}
1917
/// Raised when the obtained length is inconsistent.
2018
UnexpectedDataValueLength {
21-
description("Inconsistent data value length in data element")
19+
display("Inconsistent data value length in data element")
2220
}
2321
/// Error related to an invalid value read.
2422
ReadValue(err: InvalidValueReadError) {
25-
description("Invalid value read")
23+
display("Invalid value read: {}", err)
2624
from()
27-
cause(err)
28-
display(self_) -> ("{}: {}", self_.description(), err.description())
2925
}
3026
/// A failed attempt to cast a value to an inappropriate format.
3127
CastValue(err: CastValueError) {
32-
description("Failed value cast")
28+
display("Failed value cast: {}", err)
3329
from()
34-
cause(err)
35-
display(self_) -> ("{}: {}", self_.description(), err.description())
3630
}
3731
}
3832
}
@@ -47,59 +41,46 @@ quick_error! {
4741
pub enum InvalidValueReadError {
4842
/// The value cannot be read as a primitive value.
4943
NonPrimitiveType {
50-
description("attempted to retrieve complex value as primitive")
51-
display(self_) -> ("{}", self_.description())
44+
display("attempted to retrieve complex value as primitive")
5245
}
5346
/// The value's effective length cannot be resolved.
5447
UnresolvedValueLength {
55-
description("value length could not be resolved")
56-
display(self_) -> ("{}", self_.description())
48+
display("value length could not be resolved")
5749
}
5850
/// The value does not have the expected format.
5951
InvalidToken(got: u8, expected: &'static str) {
60-
description("Invalid token received for the expected value representation")
61-
display(self_) -> ("invalid token: expected {} but got {:?}", expected, got)
52+
display("invalid token: expected {} but got {:?}", expected, got)
6253
}
6354
/// The value does not have the expected length.
6455
InvalidLength(got: usize, expected: &'static str) {
65-
description("Invalid slice length for the expected value representation")
66-
display(self_) -> ("invalid length: expected {} but got {}", expected, got)
56+
display("invalid length: expected {} but got {}", expected, got)
6757
}
6858
/// Invalid date or time component.
6959
ParseDateTime(got: u32, expected: &'static str) {
70-
description("Invalid date/time component")
71-
display(self_) -> ("invalid date/time component: expected {} but got {}", expected, got)
60+
display("invalid date/time component: expected {} but got {}", expected, got)
7261
}
7362
/// Invalid or ambiguous combination of date with time.
7463
DateTimeZone {
75-
description("Invalid or ambiguous combination of date with time")
76-
display(self_) -> ("{}", self_.description())
64+
display("Invalid or ambiguous combination of date with time")
7765
}
7866
/// chrono error when parsing a date or time.
7967
Chrono(err: chrono::ParseError) {
80-
description("failed to parse date/time")
68+
display("failed to parse date/time: {}", err)
8169
from()
82-
cause(err)
83-
display(self_) -> ("{}", self_.source().unwrap())
8470
}
8571
/// The value cannot be parsed to a floating point number.
8672
ParseFloat(err: ParseFloatError) {
87-
description("Failed to parse text value as a floating point number")
73+
display("Failed to parse text value as a floating point number")
8874
from()
89-
cause(err)
90-
display(self_) -> ("{}", self_.description())
9175
}
9276
/// The value cannot be parsed to an integer.
9377
ParseInteger(err: ParseIntError) {
94-
description("Failed to parse text value as an integer")
78+
display("Failed to parse text value as an integer")
9579
from()
96-
cause(err)
97-
display(self_) -> ("{}", err.description())
9880
}
9981
/// An attempt of reading more than the number of bytes in the length attribute was made.
10082
UnexpectedEndOfElement {
101-
description("Unexpected end of element")
102-
display(self_) -> ("{}", self_.description())
83+
display("Unexpected end of element")
10384
}
10485
}
10586
}
@@ -118,16 +99,10 @@ impl fmt::Display for CastValueError {
11899
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
119100
write!(
120101
f,
121-
"{}: requested {} but value is {:?}",
122-
self.description(),
123-
self.requested,
124-
self.got
102+
"bad value cast: requested {} but value is {:?}",
103+
self.requested, self.got
125104
)
126105
}
127106
}
128107

129-
impl ::std::error::Error for CastValueError {
130-
fn description(&self) -> &str {
131-
"bad value cast"
132-
}
133-
}
108+
impl ::std::error::Error for CastValueError {}

encoding/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ inventory-registry = ['inventory']
1616
[dependencies]
1717
dicom-core = { path = "../core", version = "0.1.0" }
1818
dicom-dictionary-std = { path = "../dictionary-std", version = "0.1.0" }
19-
quick-error = "1.2.2"
19+
quick-error = "1.2.3"
2020
encoding = "0.2.33"
2121
byteordered = "0.5.0"
2222
inventory = { version = "0.1.4", optional = true }

encoding/src/error.rs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ pub use dicom_core::error::{CastValueError, InvalidValueReadError};
33
use dicom_core::Tag;
44
use quick_error::quick_error;
55
use std::borrow::Cow;
6-
use std::error::Error as BaseError;
76
use std::fmt;
87
use std::io;
98

@@ -16,40 +15,31 @@ quick_error! {
1615
pub enum Error {
1716
/// Raised when the obtained data element tag was not the one expected.
1817
UnexpectedTag(tag: Tag) {
19-
description("Unexpected DICOM element tag in current reading position")
2018
display("Unexpected DICOM tag {}", tag)
2119
}
2220
/// Raised when the obtained length is inconsistent.
2321
UnexpectedDataValueLength {
24-
description("Inconsistent data value length in data element")
22+
display("Inconsistent data value length in data element")
2523
}
2624
/// Error related to an invalid value read.
2725
ReadValue(err: InvalidValueReadError) {
28-
description("Invalid value read")
2926
from()
30-
cause(err)
31-
display(self_) -> ("{}: {}", self_.description(), err.description())
27+
display("Invalid value read: {}", err)
3228
}
3329
/// Error related to a failed text encoding / decoding procedure.
3430
TextEncoding(err: TextEncodingError) {
35-
description("Failed text encoding/decoding")
31+
display("Failed text encoding/decoding: {}", err)
3632
from()
37-
cause(err)
38-
display(self_) -> ("{}: {}", self_.description(), err.description())
3933
}
4034
/// A failed attempt to cast a value to an inappropriate format.
4135
CastValue(err: CastValueError) {
42-
description("Failed value cast")
36+
display("Failed value cast: {}", err)
4337
from()
44-
cause(err)
45-
display(self_) -> ("{}: {}", self_.description(), err.description())
4638
}
4739
/// Other I/O errors.
4840
Io(err: io::Error) {
49-
description("I/O error")
41+
display("I/O error: {}", err)
5042
from()
51-
cause(err)
52-
display(self_) -> ("{}: {}", self_.description(), err.description())
5343
}
5444
}
5545
}
@@ -79,12 +69,8 @@ impl TextEncodingError {
7969

8070
impl fmt::Display for TextEncodingError {
8171
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
82-
write!(f, "{}: {}", self.description(), self.0)
72+
write!(f, "encoding/decoding process failed: {}", self.0)
8373
}
8474
}
8575

86-
impl ::std::error::Error for TextEncodingError {
87-
fn description(&self) -> &str {
88-
"encoding/decoding process failed"
89-
}
90-
}
76+
impl ::std::error::Error for TextEncodingError {}

parser/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repository = "https://github.com/Enet4/dicom-rs"
1010
[dependencies]
1111
dicom-core = { path = "../core", version = "0.1.0" }
1212
dicom-encoding = { path = "../encoding", version = "0.1.0" }
13-
quick-error = "1.2.2"
13+
quick-error = "1.2.3"
1414
chrono = "0.4.6"
1515
dicom-dictionary-std = { path = "../dictionary-std/", version = "0.1.0" }
1616
smallvec = "1.0.0"

parser/src/error.rs

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ pub use dicom_core::error::{CastValueError, InvalidValueReadError};
44
use dicom_core::Tag;
55
use dicom_encoding::error::{Error as EncodingError, TextEncodingError};
66
use quick_error::quick_error;
7-
use std::error::Error as BaseError;
87
use std::fmt;
98
use 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 {
137124
impl 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
}

scpproxy/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ repository = "https://github.com/Enet4/dicom-rs"
99

1010
[dependencies]
1111
clap = "2.33.0"
12-
quick-error = "1.2.2"
12+
quick-error = "1.2.3"
1313
dicom-ul = { path = "../ul/", version = "0.1.0" }
14-
dicom-dictionary-std = { path = "../dictionary-std/", version = "0.1.0" }
14+
dicom-dictionary-std = { path = "../dictionary-std/", version = "0.1.0" }

ul/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ license = "MIT/Apache-2.0"
88
repository = "https://github.com/Enet4/dicom-rs"
99

1010
[dependencies]
11-
quick-error = "1.2.2"
11+
quick-error = "1.2.3"
1212
byteordered = "0.5.0"
1313
dicom-encoding = { path = "../encoding/", version = "0.1.0" }
1414

1515
[dev-dependencies]
16-
matches = "0.1.8"
16+
matches = "0.1.8"

0 commit comments

Comments
 (0)