Refactor recoverable Effect fallbacks to orElseSucceed (#2968)
This commit is contained in:
1 parent
a084fbbc0a
commit
9da430c828
42 files changed
+182
-318
No files matched your search
@@ -359,7 +359,7 @@ function responseError(
|
||||
response: HttpClientResponse.HttpClientResponse,
|
||||
): Effect.Effect<never, BitbucketApiError> {
|
||||
return response.text.pipe(
|
||||
Effect.catch(() => Effect.succeed("")),
|
||||
Effect.orElseSucceed(() => ""),
|
||||
Effect.flatMap((body) =>
|
||||
Effect.fail(
|
||||
new BitbucketApiError({
|
||||
@@ -524,7 +524,7 @@ export const make = Effect.fn("makeBitbucketApi")(function* () {
|
||||
);
|
||||
|
||||
const readConfigValueNullable = (cwd: string, key: string) =>
|
||||
git.readConfigValue(cwd, key).pipe(Effect.catch(() => Effect.succeed(null)));
|
||||
git.readConfigValue(cwd, key).pipe(Effect.orElseSucceed(() => null));
|
||||
|
||||
const resolveCheckoutRemote = Effect.fn("BitbucketApi.resolveCheckoutRemote")(function* (input: {
|
||||
readonly cwd: string;
|
||||
@@ -544,7 +544,7 @@ export const make = Effect.fn("makeBitbucketApi")(function* () {
|
||||
if (!input.isCrossRepository) {
|
||||
const remoteName = yield* git
|
||||
.resolvePrimaryRemoteName(input.cwd)
|
||||
.pipe(Effect.catch(() => Effect.succeed(null)));
|
||||
.pipe(Effect.orElseSucceed(() => null));
|
||||
if (remoteName) return remoteName;
|
||||
}
|
||||
|
||||
@@ -575,7 +575,7 @@ export const make = Effect.fn("makeBitbucketApi")(function* () {
|
||||
host: Option.some("bitbucket.org"),
|
||||
detail: Option.none<string>(),
|
||||
})),
|
||||
Effect.catch(() => Effect.succeed(authFromConfig(config))),
|
||||
Effect.orElseSucceed(() => authFromConfig(config)),
|
||||
),
|
||||
listPullRequests: (input) =>
|
||||
resolveRepository(input).pipe(
|
||||
@@ -685,8 +685,8 @@ export const make = Effect.fn("makeBitbucketApi")(function* () {
|
||||
{
|
||||
repository: getRepositoryFromLocator(locator),
|
||||
branchingModel: getBranchingModelFromLocator(locator).pipe(
|
||||
Effect.catch(() =>
|
||||
Effect.succeed<typeof RawBitbucketBranchingModelSchema.Type | null>(null),
|
||||
Effect.orElseSucceed(
|
||||
(): typeof RawBitbucketBranchingModelSchema.Type | null => null,
|
||||
),
|
||||
),
|
||||
},
|
||||
|
||||
@@ -299,7 +299,7 @@ export const refineUnknownRemoteProvider = Effect.fn("refineUnknownRemoteProvide
|
||||
auth,
|
||||
}),
|
||||
),
|
||||
Effect.catch(() => Effect.succeed(null)),
|
||||
Effect.orElseSucceed(() => null),
|
||||
),
|
||||
);
|
||||
const provider = providers.find((candidate) => candidate !== null);
|
||||
|
||||
@@ -277,12 +277,10 @@ export const make = Effect.fn("makeSourceControlRepositoryService")(function* ()
|
||||
})
|
||||
.pipe(
|
||||
Effect.map(() => true),
|
||||
Effect.catch(() => Effect.succeed(false)),
|
||||
Effect.orElseSucceed(() => false),
|
||||
);
|
||||
if (!hasCommits) {
|
||||
const details = yield* git
|
||||
.statusDetails(input.cwd)
|
||||
.pipe(Effect.catch(() => Effect.succeed(null)));
|
||||
const details = yield* git.statusDetails(input.cwd).pipe(Effect.orElseSucceed(() => null));
|
||||
return {
|
||||
repository: toRepositoryInfo(providerKind, urls),
|
||||
remoteName,
|
||||
|
||||
Reference in new issue
Block a user