refactor(errors): remove stale workspace failures
This commit is contained in:
@@ -95,7 +95,6 @@ export const analysisErrorProjectionSchema = z.discriminatedUnion("code", [
|
||||
generic("process_capture_failed"),
|
||||
generic("cleanup_incomplete"),
|
||||
generic("revision_conflict"),
|
||||
generic("outside_approved_root"),
|
||||
generic("configuration_invalid"),
|
||||
generic("target_unavailable"),
|
||||
generic("execution_failure"),
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
HopperProcessError,
|
||||
HopperStartError,
|
||||
HopperTimeoutError,
|
||||
WorkspaceStorageError,
|
||||
NoBinaryOpenError,
|
||||
PermissionRequiredError,
|
||||
ProviderSelectionError,
|
||||
@@ -78,8 +77,6 @@ export const analysisErrorCategory = (
|
||||
return "unavailable";
|
||||
if (error instanceof ArtifactOperationError)
|
||||
return artifactErrorCategory(error.reason);
|
||||
if (error instanceof WorkspaceStorageError)
|
||||
return workspaceStorageCategory(error.reason);
|
||||
return STATIC_ERROR_CATEGORIES[error._tag] ?? "execution_failure";
|
||||
};
|
||||
|
||||
@@ -98,21 +95,6 @@ const browserErrorCategory = (
|
||||
return "execution_failure";
|
||||
};
|
||||
|
||||
const workspaceStorageCategory = (
|
||||
reason: WorkspaceStorageError["reason"],
|
||||
): AnalysisErrorProjection["category"] => {
|
||||
if (
|
||||
reason === "disabled" ||
|
||||
reason === "outside-root" ||
|
||||
reason === "not-file"
|
||||
)
|
||||
return "unavailable";
|
||||
if (reason === "too-large") return "truncated";
|
||||
if (reason === "invalid-json" || reason === "integrity")
|
||||
return "integrity_mismatch";
|
||||
return "execution_failure";
|
||||
};
|
||||
|
||||
const artifactErrorCategory = (
|
||||
reason: ArtifactOperationError["reason"],
|
||||
): AnalysisErrorProjection["category"] => {
|
||||
@@ -156,8 +138,6 @@ export const analysisErrorUserMessage = (error: AnalysisError): string => {
|
||||
return "Evidence is invalid or has changed. Recreate or re-import it, then try again.";
|
||||
if (error instanceof EvidenceFileError)
|
||||
return evidenceFileMessage(error.reason);
|
||||
if (error instanceof WorkspaceStorageError)
|
||||
return workspaceStorageMessage(error.reason);
|
||||
if (error instanceof UnknownRegistryError && error.reason === "not-found")
|
||||
return "The requested residual unknown does not exist in this session. Check the unknown_id and try again.";
|
||||
if (error instanceof UnknownRegistryError)
|
||||
@@ -262,26 +242,6 @@ const evidenceFileMessage = (reason: EvidenceFileError["reason"]): string => {
|
||||
return "Evidence file could not be accessed. Check file permissions and try again.";
|
||||
};
|
||||
|
||||
const workspaceStorageMessage = (
|
||||
reason: WorkspaceStorageError["reason"],
|
||||
): string => {
|
||||
if (reason === "disabled")
|
||||
return "Investigation workspace access is disabled. Configure a workspace directory and try again.";
|
||||
if (reason === "outside-root")
|
||||
return "Investigation workspace is outside the allowed directory. Choose a configured workspace directory and try again.";
|
||||
if (reason === "not-file")
|
||||
return "Investigation workspace path is not a file. Choose a workspace file and try again.";
|
||||
if (reason === "too-large")
|
||||
return "Investigation workspace is too large. Reduce its size and try again.";
|
||||
if (reason === "invalid-json" || reason === "integrity")
|
||||
return "Investigation workspace is invalid or has changed. Recreate or repair it, then try again.";
|
||||
if (reason === "locked")
|
||||
return "Another investigation update is in progress. Try again when it finishes.";
|
||||
if (reason === "revision-conflict" || reason === "name-conflict")
|
||||
return "Investigation workspace state changed. Refresh the current state and try again.";
|
||||
return "Investigation workspace could not be accessed. Check file permissions and try again.";
|
||||
};
|
||||
|
||||
const KNOWN_ERROR_TAGS = {
|
||||
AnalysisProtocolError: true,
|
||||
AnalysisInputError: true,
|
||||
@@ -296,7 +256,6 @@ const KNOWN_ERROR_TAGS = {
|
||||
ProcessCaptureError: true,
|
||||
EvidenceIntegrityError: true,
|
||||
EvidenceFileError: true,
|
||||
WorkspaceStorageError: true,
|
||||
UnknownRegistryError: true,
|
||||
HopperTimeoutError: true,
|
||||
HopperCancelledError: true,
|
||||
|
||||
@@ -17,7 +17,6 @@ import {
|
||||
HopperProcessError,
|
||||
HopperRemoteError,
|
||||
HopperTimeoutError,
|
||||
WorkspaceStorageError,
|
||||
PermissionRequiredError,
|
||||
ProviderAdapterError,
|
||||
ProviderSelectionError,
|
||||
@@ -72,8 +71,6 @@ const errorCode = (error: AnalysisError): AnalysisErrorProjection["code"] => {
|
||||
if (error instanceof ArtifactOperationError)
|
||||
return artifactOperationCode(error);
|
||||
if (error instanceof EvidenceFileError) return evidenceFileCode(error.reason);
|
||||
if (error instanceof WorkspaceStorageError)
|
||||
return workspaceStorageCode(error.reason);
|
||||
if (error instanceof UnknownRegistryError)
|
||||
return unknownRegistryCode(error.reason);
|
||||
if (error._tag === "ProcessCaptureError") return processCaptureCode(error);
|
||||
@@ -112,19 +109,6 @@ const evidenceFileCode = (
|
||||
? "evidence_integrity_mismatch"
|
||||
: "execution_failure";
|
||||
|
||||
const workspaceStorageCode = (
|
||||
reason: WorkspaceStorageError["reason"],
|
||||
): AnalysisErrorProjection["code"] => {
|
||||
if (reason === "revision-conflict" || reason === "name-conflict")
|
||||
return "revision_conflict";
|
||||
if (reason === "too-large") return "truncated";
|
||||
if (reason === "disabled") return "capability_unavailable";
|
||||
if (reason === "outside-root") return "outside_approved_root";
|
||||
if (reason === "integrity" || reason === "invalid-json")
|
||||
return "evidence_integrity_mismatch";
|
||||
return "execution_failure";
|
||||
};
|
||||
|
||||
const unknownRegistryCode = (
|
||||
reason: UnknownRegistryError["reason"],
|
||||
): AnalysisErrorProjection["code"] => {
|
||||
@@ -149,7 +133,6 @@ type SpecializedErrorTag =
|
||||
| "ArtifactOperationError"
|
||||
| "BrowserObservationError"
|
||||
| "EvidenceFileError"
|
||||
| "WorkspaceStorageError"
|
||||
| "PermissionRequiredError"
|
||||
| "ProcessCaptureError"
|
||||
| "ProviderSelectionError"
|
||||
@@ -188,7 +171,6 @@ const staticErrorCode = (
|
||||
case "ArtifactOperationError":
|
||||
case "BrowserObservationError":
|
||||
case "EvidenceFileError":
|
||||
case "WorkspaceStorageError":
|
||||
case "PermissionRequiredError":
|
||||
case "ProcessCaptureError":
|
||||
case "ProviderSelectionError":
|
||||
@@ -262,8 +244,6 @@ const artifactStateErrorDetails = (
|
||||
reason: error.reason,
|
||||
...(error.reason === "limit" ? { truncated: true } : {}),
|
||||
};
|
||||
if (error instanceof WorkspaceStorageError)
|
||||
return { operation: error.operation, reason: error.reason };
|
||||
if (error instanceof UnknownRegistryError) return { reason: error.reason };
|
||||
if (error instanceof EvidenceFileError)
|
||||
return { operation: error.operation, reason: error.reason };
|
||||
|
||||
@@ -39,7 +39,6 @@ const ANALYSIS_ERROR_TAGS = [
|
||||
"ProcessCaptureError",
|
||||
"EvidenceIntegrityError",
|
||||
"EvidenceFileError",
|
||||
"WorkspaceStorageError",
|
||||
"UnknownRegistryError",
|
||||
"HopperTimeoutError",
|
||||
"HopperCancelledError",
|
||||
@@ -331,29 +330,6 @@ export class EvidenceFileError extends AnalysisError {
|
||||
}
|
||||
}
|
||||
|
||||
/** A revisioned workspace could not be read or updated. */
|
||||
export class WorkspaceStorageError extends AnalysisError {
|
||||
readonly _tag = "WorkspaceStorageError";
|
||||
|
||||
constructor(
|
||||
readonly operation: "read" | "update",
|
||||
readonly reason:
|
||||
| "disabled"
|
||||
| "outside-root"
|
||||
| "not-file"
|
||||
| "too-large"
|
||||
| "invalid-json"
|
||||
| "integrity"
|
||||
| "locked"
|
||||
| "revision-conflict"
|
||||
| "name-conflict"
|
||||
| "io",
|
||||
options?: ErrorOptions,
|
||||
) {
|
||||
super(`Workspace storage ${operation} failed: ${reason}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
/** Residual-unknown mutation failed a lifecycle, reference, or CAS invariant. */
|
||||
export class UnknownRegistryError extends AnalysisError {
|
||||
readonly _tag = "UnknownRegistryError";
|
||||
@@ -515,7 +491,6 @@ export interface AnalysisErrorProjection
|
||||
| "process_capture_failed"
|
||||
| "cleanup_incomplete"
|
||||
| "revision_conflict"
|
||||
| "outside_approved_root"
|
||||
| "configuration_invalid"
|
||||
| "target_unavailable"
|
||||
| "execution_failure"
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user