← All procedures

client.tryCatch

Try/catch wrapper for procedures

MCPCLIbrowser
Package
@procedures/client · README
Path
["client","tryCatch"]
CLI
mark client tryCatch
MCP tool
client.tryCatch on the dev-tools server
As data
{"$proc":["client","tryCatch"],"input":{}}
Tags
core, control-flow, runs-refs

Try it in the Composer →

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY, allCoreProcedures } from "@procedures/client";

for (const procedure of allCoreProcedures) {
  if (!PROCEDURE_REGISTRY.has(procedure.path)) PROCEDURE_REGISTRY.register(procedure);
}

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["client","tryCatch"], { try: "<try>", catch: "<catch>" });
console.log(JSON.stringify(result));

From the command line

$ mark client tryCatch

As data, in a program

{
  "$proc": ["client", "tryCatch"],
  "input": { "try": "<try>", "catch": "<catch>" }
}

Input

FieldTypeRequired
tryunknownyes
catchunknownyes

Output

FieldTypeRequiredDefaultDescription
successbooleanyesTrue when the try operand did not throw
valueanynoThe value of the try operand, or of the catch operand after an error
errorstringnoThe error message of the try operand
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "try": {
        "description": "The program to try"
      },
      "catch": {
        "description": "The program or value for an error. It reads the message as { $ref: \"error\" }."
      }
    },
    "additionalProperties": {}
  },
  "output": {
    "type": "object",
    "properties": {
      "success": {
        "type": "boolean",
        "description": "True when the try operand did not throw"
      },
      "value": {
        "description": "The value of the try operand, or of the catch operand after an error"
      },
      "error": {
        "description": "The error message of the try operand",
        "type": "string"
      }
    },
    "required": [
      "success"
    ],
    "additionalProperties": {}
  }
}