Command Palette

Search for a command to run...

Назад к скиллам
скилл № 48067

hoc-errors

Conventions for how code reports a failure, from a method that cannot produce its value to an abstract member a subclass has not implemented. Use when a…

БесплатноБез исполняемых скриптов
openreachtechот openreachtech★ 17 звёзд на GitHub

Установить hoc-errors в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Shared: Errors

Summarizes conventions for error handling.

Generation methods return null on failure

  • For a method that returns a generated value, return null rather than throwing an exception "when generation is not possible."
  • However, if there is a specific instruction to do so, implement it to throw an exception.
// OK: return null when generation is not possible
/**
 * @param {{
 *   length: number
 * }} params - Parameters.
 * @returns {string | null} Generated text, or null if it cannot be generated.
 */
generate ({
  length,
}) {
  if (!Number.isInteger(length) || length < 0) {
    return null
  }

  // ...
}

A delegate's failure turned into a result

  • Where a class calls a delegate — a client, a repository, a service — and reports the call's failure as a result rather than throwing it, how the call is laid out belongs to /hoc-classes-delegation.
  • What it is read for here is where the try/catch sits. The call to the delegate is isolated in an invoke~ member that catches nothing, and the try/catch belongs to the public member that calls it.

How an abstract member declares itself unimplemented

An abstract method or getter that requires an override in a subclass throws where it is reached without one. Two throws express that, and a module takes one of them throughout.

Route What is thrown Where it belongs
The plain error new Error() carrying the wording below The default, and the whole of it for a module that declares no error class of its own
The module's own error The class that module declares for its failures A module whose errors are part of what it publishes

The choice belongs to the module and is made once. A module mixing the two leaves a caller unable to say what to catch: half of its abstract members arrive as something the caller can identify and half as a bare Error, and nothing about a member says which it will be.

Two rules hold whichever route is taken — how the member is named, and that the class name is resolved rather than written down. Both are below the two routes.

The plain error

  • Unify the new Error() message to the following format.
`${<class name>}<member-notation> must be inherited`
  • Unify the wording as must be inherited, with no trailing period (.).
// OK: instance method (override required in subclass)
normalizeValue () {
  throw new Error(`${this.constructor.name}#normalizeValue() must be inherited`)
}

// OK: static getter
static get rawSchema () {
  throw new Error(`${this.name}.get:rawSchema must be inherited`)
}

// OK: static method
static generateCredential () {
  throw new Error(`${this.name}.generateCredential() must be inherited`)
}

The module's own error

A module that declares an error class so its exceptions can be told apart from anything else's has already said how its failures arrive. An abstract member left unimplemented is that module's own contract failing, so it arrives the same way — and a bare Error thrown beside it would be the one failure of that module a caller cannot place.

  • The message is the error class's, not this convention's. Where the class builds one from an error code and a value, the code and the value are what a reader sees; the must be inherited wording belongs to the plain route and is not restated here.
    • What that code is belongs to the error code convention — its parts, and the category a failure of this kind takes. This convention settles that the throw happens and what it carries the member under, never how the string identifying it is built.
  • The member goes in under the key memberName. Fixing the key buys what fixing the wording buys on the other route — whoever searches for where a member is declared abstract has one string to search for, rather than a shape that differs per module.
// OK: the module's own error, with the member named and the class resolved
static get config () {
  throw ConcreteMemberNotFoundError.create({
    value: {
      memberName: `${this.name}.get:config`,
    },
  })
}
  • Declaring the class is the module's decision, not this convention's. What settles it is whether callers are meant to catch that module's failures by type; a module nobody catches that way gains nothing from the class and takes the plain route.

The member is named as the documentation convention names it

  • <member-notation> follows /hoc-classes-member-notation (instance method #instanceMethod() / static getter .get:staticGetter / static method .staticMethod(), etc.).
  • This holds in the plain error's message and in the memberName the module's own error carries. The notation is what a reader matches against the source, so it cannot differ by route.

The class name is resolved at run time

  • <class name> is resolved dynamically, embedding the actual runtime class (subcla
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл hoc-errors?

Conventions for how code reports a failure, from a method that cannot produce its value to an abstract member a subclass has not implemented. Use when a method can fail, when the failure of a call to a delegate is turned into a result, or when declaring an abstract member. The string an error carries for its callers belongs to the error-codes convention; how the call to a delegate is laid out, to the delegation convention.

Как установить скилл hoc-errors?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл hoc-errors запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить hoc-errors с