@@ -126,7 +126,7 @@ impl IntoResponse for Error {
126
126
} ;
127
127
let error_message = self . to_string ( ) ;
128
128
129
- ( status_code, error_message) . into_response ( )
129
+ ( status_code, Json ( json ! ( { "error" : error_message } ) ) ) . into_response ( )
130
130
}
131
131
}
132
132
@@ -319,6 +319,13 @@ mod tests {
319
319
320
320
let response = app. call ( req) . await . unwrap ( ) ;
321
321
assert_eq ! ( response. status( ) , StatusCode :: NOT_FOUND ) ;
322
+
323
+ let body = response. into_body ( ) . collect ( ) . await . unwrap ( ) . to_bytes ( ) ;
324
+ let entity: Value = serde_json:: from_slice ( & body) . unwrap ( ) ;
325
+ assert_json_eq ! (
326
+ entity,
327
+ json!( { "error" : "Entity not found with topic id: device/test-child//" } )
328
+ ) ;
322
329
}
323
330
324
331
#[ tokio:: test]
@@ -410,6 +417,13 @@ mod tests {
410
417
411
418
let response = app. call ( req) . await . unwrap ( ) ;
412
419
assert_eq ! ( response. status( ) , StatusCode :: CONFLICT ) ;
420
+
421
+ let body = response. into_body ( ) . collect ( ) . await . unwrap ( ) . to_bytes ( ) ;
422
+ let entity: Value = serde_json:: from_slice ( & body) . unwrap ( ) ;
423
+ assert_json_eq ! (
424
+ entity,
425
+ json!( { "error" : "An entity with topic id: device/test-child// is already registered" } )
426
+ ) ;
413
427
}
414
428
415
429
#[ tokio:: test]
@@ -456,6 +470,13 @@ mod tests {
456
470
457
471
let response = app. call ( req) . await . unwrap ( ) ;
458
472
assert_eq ! ( response. status( ) , StatusCode :: BAD_REQUEST ) ;
473
+
474
+ let body = response. into_body ( ) . collect ( ) . await . unwrap ( ) . to_bytes ( ) ;
475
+ let entity: Value = serde_json:: from_slice ( & body) . unwrap ( ) ;
476
+ assert_json_eq ! (
477
+ entity,
478
+ json!( { "error" : "Specified parent \" test-child\" does not exist in the store" } )
479
+ ) ;
459
480
}
460
481
461
482
#[ tokio:: test]
@@ -705,6 +726,13 @@ mod tests {
705
726
706
727
let response = app. call ( req) . await . unwrap ( ) ;
707
728
assert_eq ! ( response. status( ) , StatusCode :: BAD_REQUEST ) ;
729
+
730
+ let body = response. into_body ( ) . collect ( ) . await . unwrap ( ) . to_bytes ( ) ;
731
+ let entity: Value = serde_json:: from_slice ( & body) . unwrap ( ) ;
732
+ assert_json_eq ! (
733
+ entity,
734
+ json!( { "error" : "An entity topic identifier has at most 4 segments" } )
735
+ ) ;
708
736
}
709
737
710
738
#[ tokio:: test]
@@ -722,6 +750,13 @@ mod tests {
722
750
723
751
let response = app. call ( req) . await . unwrap ( ) ;
724
752
assert_eq ! ( response. status( ) , StatusCode :: BAD_REQUEST ) ;
753
+
754
+ let body = response. into_body ( ) . collect ( ) . await . unwrap ( ) . to_bytes ( ) ;
755
+ let entity: Value = serde_json:: from_slice ( & body) . unwrap ( ) ;
756
+ assert_json_eq ! (
757
+ entity,
758
+ json!( { "error" : "The provided parameters: root and parent are mutually exclusive. Use either one." } )
759
+ ) ;
725
760
}
726
761
727
762
struct TestHandle {
0 commit comments