@@ -7,6 +7,7 @@ use crate::database::{DatabaseRef, ObjectsTreeError};
77use crate :: types:: User ;
88use crate :: providers:: index:: IndexProvider ;
99use crate :: object_diff:: { ObjectDiffModel , build_object_diff_from_change} ;
10+ use moor_var:: { v_error, E_INVARG } ;
1011
1112/// Request structure for index update operations
1213#[ derive( Debug , Clone , Serialize , Deserialize ) ]
@@ -54,7 +55,7 @@ impl IndexUpdateOperation {
5455 }
5556 None => {
5657 error ! ( "No source URL found in index - nothing to update" ) ;
57- return Ok ( moor_var :: v_str ( "Error: No source URL configured. This repository was not cloned from a remote source.") ) ;
58+ return Err ( ObjectsTreeError :: SerializationError ( " No source URL configured. This repository was not cloned from a remote source.". to_string ( ) ) ) ;
5859 }
5960 } ;
6061
@@ -318,23 +319,37 @@ impl Operation for IndexUpdateOperation {
318319 use crate :: operations:: OperationResponse ;
319320 vec ! [
320321 OperationResponse :: success(
321- "Operation executed successfully" ,
322- r#""Operation completed successfully""#
322+ "Operation executed successfully - Index is up to date" ,
323+ r#""Index is up to date""#
324+ ) ,
325+ OperationResponse :: success(
326+ "Operation executed successfully - Full clone completed" ,
327+ r#""Cloned successfully from http://example.com:8081 - 5 changes, 42 objects""#
328+ ) ,
329+ OperationResponse :: new(
330+ 400 ,
331+ "Bad Request - No source URL configured" ,
332+ r#"E_INVARG("No source URL configured. This repository was not cloned from a remote source.")"#
323333 ) ,
324334 OperationResponse :: new(
325335 400 ,
326- "Bad Request - Invalid arguments " ,
327- r#""Error: Invalid operation arguments" "#
336+ "Bad Request - Failed to parse delta from remote " ,
337+ r#"E_INVARG("Failed to parse delta: invalid JSON") "#
328338 ) ,
329339 OperationResponse :: new(
330- 404 ,
331- "Not Found - Resource not found" ,
332- r#""Error: Resource not found""#
340+ 500 ,
341+ "Internal Server Error - HTTP request to remote failed" ,
342+ r#"E_INVARG("HTTP request failed: connection refused")"#
343+ ) ,
344+ OperationResponse :: new(
345+ 500 ,
346+ "Internal Server Error - Channel closed during update" ,
347+ r#"E_INVARG("Channel closed during update")"#
333348 ) ,
334349 OperationResponse :: new(
335350 500 ,
336351 "Internal Server Error - Database or system error" ,
337- r#""Error: Database error: operation failed" "#
352+ r#"E_INVARG(" Database error: failed to get change order") "#
338353 ) ,
339354 ]
340355 }
@@ -351,7 +366,7 @@ impl Operation for IndexUpdateOperation {
351366 }
352367 Err ( e) => {
353368 error ! ( "Index update operation failed: {}" , e) ;
354- moor_var :: v_str ( & format ! ( "Error: {e}" ) )
369+ v_error ( E_INVARG . msg ( format ! ( "{e}" ) ) )
355370 }
356371 }
357372 }
0 commit comments