Wymcp.ConfigurationError exception (Wymcp v0.9.1)

View Source

A configuration refusal is wymcp's refusal of a configuration — a tool's declaration or a mount's options — raised at the tool-module moment, at the registration moment, or by an obtaining moment's re-check, and carrying the callback at fault where one callback is.

It is not a refusal in the request sense: no request is being answered. Its reader is the author of the configuration, and its message names what to fix — the message text is each check's own, and this type does not change it.

Fields

  • :message — the configuration refusal's text.
  • :module — the module whose declaration is refused, when the configuration refusal is about one module: a tool, or the :auth module. nil when it is about a mount's options or about several modules at once — an unknown option key, two tools sharing a name.
  • :callback — the callback whose return is refused, as {name, arity}, when one callback is at fault. nil when none is: a module that cannot be loaded, or one missing a required callback, has no definition to point at.

Why a type of its own

The tool-module moment calls the consumer's callbacks while it checks what they return, so a raise out of that check is either wymcp refusing the tool or the consumer's own code failing — a callback reading absent application config, say. The two want different reports: wymcp's configuration refusal is located at the tool's file, on the callback's own def line (see "When schemas are validated" in Wymcp.Tool), while the consumer's own raise keeps its message and stack trace, which point at their bug. This type is what tells them apart, whoever wrote the callback, and :module tells a configuration refusal of the module being checked from one of another module that a callback reached — that one passes through as it was raised.

At the registration moment, and at an obtaining moment, a configuration refusal is raised like any exception: the compiler's banner names the mount module's file, or the request's fault containment answers it.

Runtime argument errors are not configuration refusals and stay ArgumentError: Wymcp.Hint.new/1 given a wrong field, Wymcp.Context.elicit/4 outside a tool run, and a run/2 return outside its contract, which Wymcp.Methods.ToolsCall raises into its own fault containment.