(u: unknown): u is CronParseErrorChecks whether a given value is a CronParseError instance.
When to use
Use to narrow an unknown failure before handling it as a cron parse error.
Details
This function is a type guard that determines whether the provided value is a CronParseError by checking for the presence of the CronParseError type identifier.
Example (Checking cron parse errors)
import { Cron, Result } from "effect"
const result = Cron.parse("invalid cron expression")
if (Result.isFailure(result)) {
const error = result.failure
console.log(Cron.isCronParseError(error)) // true
}
console.log(Cron.isCronParseError(new Error("regular error"))) // false
console.log(Cron.isCronParseError("not an error")) // falseexport const const isCronParseError: (
u: unknown
) => u is CronParseError
Checks whether a given value is a CronParseError instance.
When to use
Use to narrow an unknown failure before handling it as a cron parse error.
Details
This function is a type guard that determines whether the provided
value is a CronParseError by checking for the presence of the
CronParseError type identifier.
Example (Checking cron parse errors)
import { Cron, Result } from "effect"
const result = Cron.parse("invalid cron expression")
if (Result.isFailure(result)) {
const error = result.failure
console.log(Cron.isCronParseError(error)) // true
}
console.log(Cron.isCronParseError(new Error("regular error"))) // false
console.log(Cron.isCronParseError("not an error")) // false
isCronParseError = (u: unknownu: unknown): u: unknownu is class CronParseErrorclass CronParseError {
name: string;
message: string;
stack: string;
cause: unknown;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
_tag: Tag;
input: string | undefined;
}
Represents an error that occurs when parsing a cron expression fails.
When to use
Use to handle invalid cron expression failures returned by parse.
Details
This error provides information about what went wrong during parsing,
including the error message and optionally the input that caused the error.
Example (Handling cron parse failures)
import { Cron, Result } from "effect"
const result = Cron.parse("invalid expression")
if (Result.isFailure(result)) {
const error: Cron.CronParseError = result.failure
console.log(error.message) // "Invalid number of segments in cron expression"
console.log(error.input) // "invalid expression"
}
CronParseError => hasProperty<"~effect/time/Cron/CronParseError">(self: unknown, property: "~effect/time/Cron/CronParseError"): self is { [K in "~effect/time/Cron/CronParseError"]: unknown; } (+1 overload)Checks whether a value has a given property key.
When to use
Use when you need a Predicate guard for property access on unknown
values with a simple structural object check.
Details
Uses the in operator and isObjectKeyword. This does not check property
value types.
Example (Guarding object properties)
import { Predicate } from "effect"
const hasName = Predicate.hasProperty("name")
const data: unknown = { name: "Ada" }
if (hasName(data)) {
console.log(data.name)
}
hasProperty(u: unknownu, const CronParseErrorTypeId: "~effect/time/Cron/CronParseError"CronParseErrorTypeId)