errors: typed helpers for every documented error type
AlexaErrors has a helper for each of the 73 types of the table on alexa-errorresponse.html, named after the type in camel case: 63 take the message only, 10 take the payload fields their page documents. A field the page requires (reason, currentDeviceMode, currentChargeState, resourceType) is a required argument, so leaving it out does not compile; from JavaScript the helper throws a TypeError that lists the values. validRange is optional, as the page says, and has both ends when given. temperatureOutOfRange and setpointsTooClose stay as shorter names. The helpers are compared with the 15 examples of the four error pages. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
4a3dd81bcf
commit
94b13f733a
36 changed files with 874 additions and 138 deletions
|
|
@ -147,6 +147,9 @@ const ERROR_TYPES_BY_NAMESPACE = {
|
|||
"Alexa.ThermostatController.Schedule": ["INSUFFICIENT_SPACE"],
|
||||
} as const;
|
||||
|
||||
/** "ENDPOINT_UNREACHABLE": a type of the table. */
|
||||
export type ErrorType = (typeof ERROR_TYPES_BY_NAMESPACE)[keyof typeof ERROR_TYPES_BY_NAMESPACE][number];
|
||||
|
||||
/** The 73 error types of the table, each with the namespace its ErrorResponse goes under. */
|
||||
export const ERROR_TYPES: Readonly<Record<string, string>> = Object.fromEntries(
|
||||
Object.entries(ERROR_TYPES_BY_NAMESPACE).flatMap(([namespace, types]) => types.map((type) => [type, namespace]))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue