@@ -298,17 +298,34 @@ async fn get_operations_from_content_endpoint(
298
298
. header ( user_forward_header, "admin" )
299
299
. send ( )
300
300
. await
301
- . unwrap ( )
302
- . bytes_stream ( )
303
- . map_err ( |e| std:: io:: Error :: new ( ErrorKind :: Other , e) ) ;
304
- let lines = StreamReader :: new ( res) . lines ( ) ;
305
- let lines_stream = LinesStream :: new ( lines) ;
306
- let fp = lines_stream. and_then ( |l| {
307
- future:: ready (
308
- serde_json:: from_str ( & l) . map_err ( |e| std:: io:: Error :: new ( ErrorKind :: Other , e) ) ,
309
- )
310
- } ) ;
311
- Ok ( fp)
301
+ . unwrap ( ) ;
302
+ let status = res. status ( ) ;
303
+ if status != StatusCode :: OK {
304
+ let raw_s = res
305
+ . bytes ( )
306
+ . await
307
+ . map_err ( |e| std:: io:: Error :: new ( ErrorKind :: Other , e) ) ?;
308
+ let s = String :: from_utf8_lossy ( & raw_s) ;
309
+ Err ( io:: Error :: new (
310
+ io:: ErrorKind :: Other ,
311
+ format ! (
312
+ "terminusdb indexer endpoint failed with status code {}:\n {}" ,
313
+ status, s
314
+ ) ,
315
+ ) )
316
+ } else {
317
+ let res = res
318
+ . bytes_stream ( )
319
+ . map_err ( |e| std:: io:: Error :: new ( ErrorKind :: Other , e) ) ;
320
+ let lines = StreamReader :: new ( res) . lines ( ) ;
321
+ let lines_stream = LinesStream :: new ( lines) ;
322
+ let fp = lines_stream. and_then ( |l| {
323
+ future:: ready (
324
+ serde_json:: from_str ( & l) . map_err ( |e| std:: io:: Error :: new ( ErrorKind :: Other , e) ) ,
325
+ )
326
+ } ) ;
327
+ Ok ( fp)
328
+ }
312
329
}
313
330
314
331
#[ derive( Debug , Error ) ]
@@ -434,7 +451,7 @@ impl Service {
434
451
index_id : & str ,
435
452
content_endpoint : String ,
436
453
) -> Result < ( String , HnswIndex ) , IndexError > {
437
- let internal_task_id = task_id. clone ( ) ;
454
+ let internal_task_id = task_id;
438
455
let opstream = get_operations_from_content_endpoint (
439
456
content_endpoint. to_string ( ) ,
440
457
self . user_forward_header . clone ( ) ,
0 commit comments