Skip to content

Commit 5b1b3a9

Browse files
committed
Updating more documentation.
1 parent dc93a4b commit 5b1b3a9

File tree

2 files changed

+30
-24
lines changed

2 files changed

+30
-24
lines changed

vcs-worker/src/operations/index/index_update_op.rs

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::database::{DatabaseRef, ObjectsTreeError};
77
use crate::types::User;
88
use crate::providers::index::IndexProvider;
99
use 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
}

vcs-worker/src/operations/system/status_op.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::database::{DatabaseRef, ObjectsTreeError};
66
use crate::types::{User, ChangeStatus};
77
use crate::providers::index::IndexProvider;
88
use crate::providers::workspace::WorkspaceProvider;
9+
use moor_var::{v_error, E_INVARG};
910

1011
/// System status operation that provides comprehensive repository status information
1112
#[derive(Clone)]
@@ -195,22 +196,12 @@ impl Operation for StatusOperation {
195196
vec![
196197
OperationResponse::success(
197198
"Operation executed successfully",
198-
r#""Operation completed successfully""#
199-
),
200-
OperationResponse::new(
201-
400,
202-
"Bad Request - Invalid arguments",
203-
r#""Error: Invalid operation arguments""#
204-
),
205-
OperationResponse::new(
206-
404,
207-
"Not Found - Resource not found",
208-
r#""Error: Resource not found""#
199+
r#"["game_name" -> "MyGame", "top_change_id" -> "abc123def456...", "top_change_short_id" -> "abc123", "idle_changes" -> 2, "pending_review" -> 1, "current_username" -> "player", "changes_in_index" -> 5, "latest_merged_change" -> ["id" -> "def789ghi012...", "short_id" -> "def789", "author" -> "player", "timestamp" -> 1697040000, "message" -> "Fixed login bug"], "index_partition_size" -> 1048576, "refs_partition_size" -> 4096, "objects_partition_size" -> 8388608, "remote_url" -> "http://example.com/repo", "pending_updates" -> 0]"#
209200
),
210201
OperationResponse::new(
211202
500,
212-
"Internal Server Error - Database or system error",
213-
r#""Error: Database error: operation failed""#
203+
"Internal Server Error - Database error",
204+
r#"E_INVARG("Database error: failed to get change order")"#
214205
),
215206
]
216207
}
@@ -225,7 +216,7 @@ impl Operation for StatusOperation {
225216
}
226217
Err(e) => {
227218
error!("System status operation failed: {}", e);
228-
moor_var::v_str(&format!("Error: {e}"))
219+
v_error(E_INVARG.msg(format!("{e}")))
229220
}
230221
}
231222
}

0 commit comments

Comments
 (0)