Pudu programming language
Menu
Package

@chrismichaelps / pudu-lang-mcp

Model Context Protocol server for Pudu language documentation and compiler tools

0.1.1Apache-2.01

InstallClose

ToolError.pudu

Pudu38 lines1.7 KB

GitHub ↗
1/** @Errors.ToolError.Module — recoverable tool execution failures */2module PuduLangMcp.Errors.ToolError34import PuduLangMcp.Constants.Server as Server56/** @Errors.ToolError.ToolFailure — failures reported as tool results */7export type ToolFailure8  = MissingArgument(Str)9  | WrongType(Str, Str)10  | UnknownArgument(Str)11  | OutOfRange(Str, Str)12  | NotAnObject13  | ExactlyOne(Array[Str])14  | ToolchainMissing15  | OutsideWorkspace(Str)16  | NotFound(Str)17  | TimedOut(Str, Int)18  | CommandFailed(Str)19  | Unavailable(Str)2021/// One sentence saying what went wrong and what to do next.22export fn explain(failure: &ToolFailure) -> Str {23  match failure {24    case MissingArgument(name) => "Missing required argument '" + name + "'."25    case WrongType(name, expected) => "Argument '" + name + "' must be " + expected + "."26    case UnknownArgument(name) => "Unknown argument '" + name + "'; remove it."27    case OutOfRange(name, allowed) => "Argument '" + name + "' must be " + allowed + "."28    case NotAnObject => "Arguments must be a JSON object."29    case ExactlyOne(names) => "Give exactly one of " + names.map(|name: Str| "'" + name + "'").join(" or ") + "."30    case ToolchainMissing => "The pudu compiler was not found. Install it from https://www.pudu-lang.org/download and put it on PATH, or set " + Server.ENV_PUDU_BIN + " to its path."31    case OutsideWorkspace(path) => "'" + path + "' is not an existing path inside the workspace. Use a path relative to the workspace root, or pass the code as 'source'."32    case NotFound(what) => what + " was not found."33    case TimedOut(command, millis) => "'" + command + "' did not finish within " + show(millis) + " ms and was stopped."34    case CommandFailed(detail) => "The command could not be started: " + detail35    case Unavailable(reason) => reason36  }37}38