Skip to content

Commit 1079b6c

Browse files
authored
Revert error category change
1 parent bce94c9 commit 1079b6c

File tree

3 files changed

+28
-22
lines changed

3 files changed

+28
-22
lines changed

ntex-error/src/info.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ trait ErrorInformation: fmt::Display + fmt::Debug + 'static {
77

88
fn service(&self) -> Option<&'static str>;
99

10-
fn category(&self) -> &'static str;
10+
fn signature(&self) -> &'static str;
1111

1212
fn backtrace(&self) -> Option<&Backtrace>;
1313

@@ -28,8 +28,8 @@ where
2828
ErrorDiagnostic::service(self)
2929
}
3030

31-
fn category(&self) -> &'static str {
32-
self.kind().category()
31+
fn signature(&self) -> &'static str {
32+
self.kind().signature()
3333
}
3434

3535
fn backtrace(&self) -> Option<&Backtrace> {
@@ -59,8 +59,8 @@ impl ErrorInfo {
5959
self.inner.service()
6060
}
6161

62-
pub fn category(&self) -> &'static str {
63-
self.inner.category()
62+
pub fn signature(&self) -> &'static str {
63+
self.inner.signature()
6464
}
6565

6666
pub fn backtrace(&self) -> Option<&Backtrace> {
@@ -120,7 +120,7 @@ impl ResultKind for ErrorInfoType {
120120
self.0
121121
}
122122

123-
fn category(&self) -> &'static str {
123+
fn signature(&self) -> &'static str {
124124
self.1
125125
}
126126
}
@@ -129,7 +129,7 @@ impl ErrorDiagnostic for ErrorInfo {
129129
type Kind = ErrorInfoType;
130130

131131
fn kind(&self) -> ErrorInfoType {
132-
ErrorInfoType(self.tp(), self.inner.category())
132+
ErrorInfoType(self.tp(), self.inner.signature())
133133
}
134134

135135
fn service(&self) -> Option<&'static str> {

ntex-error/src/lib.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,24 @@ pub trait ResultKind: fmt::Debug + 'static {
5959
/// Defines type of the error
6060
fn tp(&self) -> ResultType;
6161

62-
/// Error category
63-
fn category(&self) -> &'static str;
62+
/// Error signature
63+
fn signature(&self) -> &'static str;
6464
}
6565

6666
pub trait ErrorKind: fmt::Debug + 'static {
6767
/// Defines type of the error
6868
fn tp(&self) -> ResultType;
6969

70-
/// Error category
71-
fn category(&self) -> &'static str;
70+
/// Error signature
71+
fn signature(&self) -> &'static str;
7272
}
7373

7474
impl ResultKind for ResultType {
7575
fn tp(&self) -> ResultType {
7676
*self
7777
}
7878

79-
fn category(&self) -> &'static str {
79+
fn signature(&self) -> &'static str {
8080
self.as_str()
8181
}
8282
}
@@ -141,7 +141,7 @@ mod tests {
141141
}
142142
}
143143

144-
fn category(&self) -> &'static str {
144+
fn signature(&self) -> &'static str {
145145
match self {
146146
TestKind::Connect => "Client-Connect",
147147
TestKind::Disconnect => "Client-Disconnect",
@@ -201,7 +201,7 @@ mod tests {
201201
assert_eq!((*err).kind(), TestKind::ServiceError);
202202
assert_eq!(err.to_string(), "InternalServiceError");
203203
assert_eq!(err.service(), Some("test"));
204-
assert_eq!(err.kind().category(), "Service-Internal");
204+
assert_eq!(err.kind().signature(), "Service-Internal");
205205
assert_eq!(
206206
err,
207207
Into::<Error<TestError>>::into(TestError::Service("409 Error"))
@@ -239,11 +239,17 @@ mod tests {
239239
assert_eq!(format!("{}", ResultType::ClientError), "ClientError");
240240

241241
assert_eq!(TestKind::Connect.to_string(), "Connect");
242-
assert_eq!(TestError::Connect("").kind().category(), "Client-Connect");
242+
assert_eq!(TestError::Connect("").kind().signature(), "Client-Connect");
243243
assert_eq!(TestKind::Disconnect.to_string(), "Disconnect");
244-
assert_eq!(TestError::Disconnect.kind().category(), "Client-Disconnect");
244+
assert_eq!(
245+
TestError::Disconnect.kind().signature(),
246+
"Client-Disconnect"
247+
);
245248
assert_eq!(TestKind::ServiceError.to_string(), "ServiceError");
246-
assert_eq!(TestError::Service("").kind().category(), "Service-Internal");
249+
assert_eq!(
250+
TestError::Service("").kind().signature(),
251+
"Service-Internal"
252+
);
247253

248254
let err = err.into_error().chain();
249255
assert_eq!(err.kind(), TestKind::ServiceError);
@@ -273,7 +279,7 @@ mod tests {
273279
assert_eq!(err.kind(), TestKind::ServiceError);
274280
assert_eq!(err.kind(), TestError::Service("404 Error").kind());
275281
assert_eq!(err.service(), Some("test"));
276-
assert_eq!(err.kind().category(), "Service-Internal");
282+
assert_eq!(err.kind().signature(), "Service-Internal");
277283
assert_eq!(err.to_string(), "InternalServiceError");
278284
assert!(err.backtrace().is_some());
279285
assert!(format!("{err:?}").contains("Service(\"404 Error\")"));
@@ -282,7 +288,7 @@ mod tests {
282288
assert_eq!(8, mem::size_of::<Error<TestError>>());
283289

284290
assert_eq!(TestError2.service(), None);
285-
assert_eq!(TestError2.kind().category(), "ClientError");
291+
assert_eq!(TestError2.kind().signature(), "ClientError");
286292

287293
// ErrorInformation
288294
let err: Error<TestError> = TestError::Service("409 Error").into();
@@ -294,7 +300,7 @@ mod tests {
294300
let err: ErrorInfo = err.set_service("SVC").into();
295301
assert_eq!(err.tp(), ResultType::ServiceError);
296302
assert_eq!(err.service(), Some("SVC"));
297-
assert_eq!(err.category(), "Service-Internal");
303+
assert_eq!(err.signature(), "Service-Internal");
298304
assert!(err.backtrace().is_some());
299305

300306
let res = Err(TestError::Service("409 Error"));
@@ -327,7 +333,7 @@ mod tests {
327333
.try_map(|_| Err::<(), _>(TestError2))
328334
.err()
329335
.unwrap();
330-
assert_eq!(err3.kind().category(), "ClientError");
336+
assert_eq!(err3.kind().signature(), "ClientError");
331337
assert_eq!(err3.get_item::<&str>(), Some(&"Test"));
332338

333339
let res = err.clone().try_map(|_| Ok::<_, TestError2>(()));

ntex-error/src/message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ where
6767

6868
writeln!(f, "err: {e}")?;
6969
writeln!(f, "type: {}", tp.as_str())?;
70-
writeln!(f, "category: {}", k.category())?;
70+
writeln!(f, "signature: {}", k.signature())?;
7171

7272
if let Some(svc) = e.service() {
7373
writeln!(f, "service: {svc}")?;

0 commit comments

Comments
 (0)