[codex] Enrich source-control errors (#3248)

Co-authored-by: codex <[email protected]>
This commit is contained in:
Julius Marmingeandcodex authored and GitHub committed 2026-06-20 12:32:34 -07:00
1 parent 569b3e5959
commit 630df6b986
20 files changed
+1086 -341

No files matched your search

@@ -17,18 +17,6 @@ import {
} from "./SourceControlProviderDiscovery.ts";
import { findAuthenticatedGitLabHost, parseGitLabAuthStatusHosts } from "./gitLabAuthStatus.ts";
function providerError(
operation: string,
cause: GitLabCli.GitLabCliError,
): SourceControlProviderError {
return new SourceControlProviderError({
provider: "gitlab",
operation,
detail: cause.detail,
cause,
});
}
function toChangeRequest(summary: GitLabCli.GitLabMergeRequestSummary): ChangeRequest {
return {
provider: "gitlab",
@@ -129,13 +117,39 @@ export const make = Effect.gen(function* () {
})
.pipe(
Effect.map((items) => items.map(toChangeRequest)),
Effect.mapError((error) => providerError("listChangeRequests", error)),
Effect.mapError(
(error) =>
new SourceControlProviderError({
provider: "gitlab",
operation: "listChangeRequests",
command: error.command,
cwd: input.cwd,
reference: SourceControlProvider.transportSafeSourceControlErrorValue(
input.headSelector,
),
detail: error.detail,
cause: error,
}),
),
);
},
getChangeRequest: (input) =>
gitlab.getMergeRequest(input).pipe(
Effect.map(toChangeRequest),
Effect.mapError((error) => providerError("getChangeRequest", error)),
Effect.mapError(
(error) =>
new SourceControlProviderError({
provider: "gitlab",
operation: "getChangeRequest",
command: error.command,
cwd: input.cwd,
reference: SourceControlProvider.transportSafeSourceControlErrorValue(
input.reference,
),
detail: error.detail,
cause: error,
}),
),
),
createChangeRequest: (input) => {
const source = SourceControlProvider.sourceControlRefFromInput(input);
@@ -149,24 +163,88 @@ export const make = Effect.gen(function* () {
title: input.title,
bodyFile: input.bodyFile,
})
.pipe(Effect.mapError((error) => providerError("createChangeRequest", error)));
.pipe(
Effect.mapError(
(error) =>
new SourceControlProviderError({
provider: "gitlab",
operation: "createChangeRequest",
command: error.command,
cwd: input.cwd,
reference: SourceControlProvider.transportSafeSourceControlErrorValue(
input.headSelector,
),
detail: error.detail,
cause: error,
}),
),
);
},
getRepositoryCloneUrls: (input) =>
gitlab
.getRepositoryCloneUrls(input)
.pipe(Effect.mapError((error) => providerError("getRepositoryCloneUrls", error))),
gitlab.getRepositoryCloneUrls(input).pipe(
Effect.mapError(
(error) =>
new SourceControlProviderError({
provider: "gitlab",
operation: "getRepositoryCloneUrls",
command: error.command,
cwd: input.cwd,
repository: SourceControlProvider.transportSafeSourceControlErrorValue(
input.repository,
),
detail: error.detail,
cause: error,
}),
),
),
createRepository: (input) =>
gitlab
.createRepository(input)
.pipe(Effect.mapError((error) => providerError("createRepository", error))),
gitlab.createRepository(input).pipe(
Effect.mapError(
(error) =>
new SourceControlProviderError({
provider: "gitlab",
operation: "createRepository",
command: error.command,
cwd: input.cwd,
repository: SourceControlProvider.transportSafeSourceControlErrorValue(
input.repository,
),
detail: error.detail,
cause: error,
}),
),
),
getDefaultBranch: (input) =>
gitlab
.getDefaultBranch(input)
.pipe(Effect.mapError((error) => providerError("getDefaultBranch", error))),
gitlab.getDefaultBranch(input).pipe(
Effect.mapError(
(error) =>
new SourceControlProviderError({
provider: "gitlab",
operation: "getDefaultBranch",
command: error.command,
cwd: input.cwd,
detail: error.detail,
cause: error,
}),
),
),
checkoutChangeRequest: (input) =>
gitlab
.checkoutMergeRequest(input)
.pipe(Effect.mapError((error) => providerError("checkoutChangeRequest", error))),
gitlab.checkoutMergeRequest(input).pipe(
Effect.mapError(
(error) =>
new SourceControlProviderError({
provider: "gitlab",
operation: "checkoutChangeRequest",
command: error.command,
cwd: input.cwd,
reference: SourceControlProvider.transportSafeSourceControlErrorValue(
input.reference,
),
detail: error.detail,
cause: error,
}),
),
),
});
});