Skip to content

Commit

Permalink
rename ScheduleError to ScheduleDefect
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Jan 10, 2024
1 parent 0d0dc88 commit 9f237ef
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions packages/effect/src/internal/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1835,22 +1835,22 @@ export const findNextMonth = (now: number, day: number, months: number): number

// circular with Effect

const ScheduleErrorTypeId = Symbol.for("effect/Schedule/ScheduleError")
class ScheduleError<E> {
readonly [ScheduleErrorTypeId]: typeof ScheduleErrorTypeId
const ScheduleDefectTypeId = Symbol.for("effect/Schedule/ScheduleDefect")
class ScheduleDefect<E> {
readonly [ScheduleDefectTypeId]: typeof ScheduleDefectTypeId
constructor(readonly error: E) {
this[ScheduleErrorTypeId] = ScheduleErrorTypeId
this[ScheduleDefectTypeId] = ScheduleDefectTypeId
}
}
const isScheduleError = <E = unknown>(u: unknown): u is ScheduleError<E> => hasProperty(u, ScheduleErrorTypeId)
const scheduleErrorWrap = <R, E, A>(self: Effect.Effect<R, E, A>) =>
core.catchAll(self, (e) => core.die(new ScheduleError(e)))
const scheduleErrorRefail = <R, E, A>(self: Effect.Effect<R, E, A>) =>
const isScheduleDefect = <E = unknown>(u: unknown): u is ScheduleDefect<E> => hasProperty(u, ScheduleDefectTypeId)
const scheduleDefectWrap = <R, E, A>(self: Effect.Effect<R, E, A>) =>
core.catchAll(self, (e) => core.die(new ScheduleDefect(e)))
const scheduleDefectRefail = <R, E, A>(self: Effect.Effect<R, E, A>) =>
core.catchAllCause(self, (cause) =>
Option.match(
internalCause.find(
cause,
(_) => internalCause.isDieType(_) && isScheduleError<E>(_.defect) ? Option.some(_.defect) : Option.none()
(_) => internalCause.isDieType(_) && isScheduleDefect<E>(_.defect) ? Option.some(_.defect) : Option.none()
),
{
onNone: () => core.failCause(cause),
Expand Down Expand Up @@ -1900,7 +1900,7 @@ export const repeat_combined = dual<{
if (typeof applied === "boolean") {
return core.succeed(applied)
}
return scheduleErrorWrap(applied)
return scheduleDefectWrap(applied)
}) :
base
const withUntil = options.until ?
Expand All @@ -1909,14 +1909,14 @@ export const repeat_combined = dual<{
if (typeof applied === "boolean") {
return core.succeed(applied)
}
return scheduleErrorWrap(applied)
return scheduleDefectWrap(applied)
}) :
withWhile
const withTimes = options.times ?
intersect(withUntil, recurs(options.times)) :
withUntil

return scheduleErrorRefail(repeat_Effect(self, withTimes))
return scheduleDefectRefail(repeat_Effect(self, withTimes))
}
)

Expand Down Expand Up @@ -1997,7 +1997,7 @@ export const retry_combined = dual<{
if (typeof applied === "boolean") {
return core.succeed(applied)
}
return scheduleErrorWrap(applied)
return scheduleDefectWrap(applied)
}) :
base
const withUntil = options.until ?
Expand All @@ -2006,13 +2006,13 @@ export const retry_combined = dual<{
if (typeof applied === "boolean") {
return core.succeed(applied)
}
return scheduleErrorWrap(applied)
return scheduleDefectWrap(applied)
}) :
withWhile
const withTimes = options.times ?
intersect(withUntil, recurs(options.times)) :
withUntil
return scheduleErrorRefail(retry_Effect(self, withTimes))
return scheduleDefectRefail(retry_Effect(self, withTimes))
}
)

Expand Down

0 comments on commit 9f237ef

Please sign in to comment.