Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/client/src/schedule-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ export class ScheduleClient extends BaseClient {
const res = await this.workflowService.createSchedule(req);
return { conflictToken: res.conflictToken };
} catch (err: any) {
if (err instanceof TypeError) throw err;
if (err.code === grpcStatus.ALREADY_EXISTS) {
throw new ScheduleAlreadyRunning('Schedule already exists and is running', opts.scheduleId);
}
Expand Down Expand Up @@ -305,6 +306,7 @@ export class ScheduleClient extends BaseClient {
requestId: uuid4(),
});
} catch (err: any) {
if (err instanceof TypeError) throw err;
this.rethrowGrpcError(err, scheduleId, 'Failed to update schedule');
}
}
Expand Down
10 changes: 5 additions & 5 deletions packages/client/src/schedule-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ const [encodeMinute, decodeMinue] = makeCalendarSpecFieldCoders(

const [encodeHour, decodeHour] = makeCalendarSpecFieldCoders(
'hour',
(x: number) => (typeof x === 'number' && x >= 0 && x <= 59 ? x : undefined),
(x: number) => (typeof x === 'number' && x >= 0 && x <= 23 ? x : undefined),
(x: number) => x,
[{ start: 0, end: 0, step: 0 }], // default to 0
[{ start: 0, end: 23, step: 1 }]
);

const [encodeDayOfMonth, decodeDayOfMonth] = makeCalendarSpecFieldCoders(
'dayOfMonth',
(x: number) => (typeof x === 'number' && x >= 0 && x <= 6 ? x : undefined),
(x: number) => (typeof x === 'number' && x >= 0 && x <= 31 ? x : undefined),
(x: number) => x,
[{ start: 1, end: 31, step: 1 }], // default to *
[{ start: 1, end: 31, step: 1 }]
Expand Down Expand Up @@ -139,7 +139,7 @@ function makeCalendarSpecFieldCoders<Unit>(
const value = encodeValueFn(item as Unit);
if (value !== undefined) return { start: value, end: value, step: 1 };
}
throw new Error(`Invalid CalendarSpec component for field ${fieldName}: '${item}' of type '${typeof item}'`);
throw new TypeError(`Invalid CalendarSpec component for field ${fieldName}: '${item}' of type '${typeof item}'`);
});
}

Expand Down Expand Up @@ -349,7 +349,7 @@ export async function decodeScheduleAction(
workflowTaskTimeout: optionalTsToMs(pb.startWorkflow.workflowTaskTimeout),
};
}
throw new Error('Unsupported schedule action');
throw new TypeError('Unsupported schedule action');
}

export function decodeSearchAttributes(
Expand Down Expand Up @@ -397,7 +397,7 @@ export function decodeScheduleRecentActions(
firstExecutionRunId: executionResult.startWorkflowResult!.runId!,
},
};
} else throw new Error('Unsupported schedule action');
} else throw new TypeError('Unsupported schedule action');

return {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Expand Down