@@ -126,7 +126,7 @@ impl IntoResponse for Error {
126126 } ;
127127 let error_message = self . to_string ( ) ;
128128
129- ( status_code, error_message) . into_response ( )
129+ ( status_code, Json ( json ! ( { "error" : error_message } ) ) ) . into_response ( )
130130 }
131131}
132132
@@ -319,6 +319,13 @@ mod tests {
319319
320320 let response = app. call ( req) . await . unwrap ( ) ;
321321 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+ ) ;
322329 }
323330
324331 #[ tokio:: test]
@@ -410,6 +417,13 @@ mod tests {
410417
411418 let response = app. call ( req) . await . unwrap ( ) ;
412419 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+ ) ;
413427 }
414428
415429 #[ tokio:: test]
@@ -456,6 +470,13 @@ mod tests {
456470
457471 let response = app. call ( req) . await . unwrap ( ) ;
458472 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+ ) ;
459480 }
460481
461482 #[ tokio:: test]
@@ -705,6 +726,13 @@ mod tests {
705726
706727 let response = app. call ( req) . await . unwrap ( ) ;
707728 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+ ) ;
708736 }
709737
710738 #[ tokio:: test]
@@ -722,6 +750,13 @@ mod tests {
722750
723751 let response = app. call ( req) . await . unwrap ( ) ;
724752 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+ ) ;
725760 }
726761
727762 struct TestHandle {
0 commit comments