Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:8beeeaaat Touchdesigner mcp Error Categorization

From Leeroopedia
Knowledge Sources
Domains Error_Handling, Error_Classification
Last Updated 2026-10-28 00:00 GMT

Overview

A classification scheme that maps exceptions to a fixed set of semantic error categories so that callers and HTTP layers can map errors to status codes without re-inspecting exception types.

Description

When a service layer can raise many different exception types, the HTTP controller needs a uniform way to decide the response status. The error categorization principle defines a closed enum of categories (INTERNAL, VALIDATION, NOT_FOUND, PERMISSION, NETWORK, EXTERNAL) and a classifier that inspects both the exception type (e.g. ValueError → VALIDATION, FileNotFoundError → NOT_FOUND) and the error message keywords ("permission" → PERMISSION, "network"/"connection" → NETWORK). A decorator wraps service methods so every exception is caught, categorized, logged with traceback, and converted to a Result carrying the formatted message and an `errorCategory` metadata field. The controller then maps the category to an HTTP status reason without coupling to the original exception.

Usage

Use this principle when a Python service layer raises heterogeneous exceptions and the HTTP layer needs a stable, small set of status-code-mappable categories.

Theoretical Basis

# Abstract algorithm (NOT real implementation)
CATEGORIES = {INTERNAL, VALIDATION, NOT_FOUND, PERMISSION, NETWORK, EXTERNAL}

def categorize(exc):
    if isinstance(exc, ValueError): return VALIDATION
    if isinstance(exc, FileNotFoundError) or "not found" in str(exc): return NOT_FOUND
    if "permission" in str(exc): return PERMISSION
    if "network" in str(exc) or "connection" in str(exc): return NETWORK
    return INTERNAL

def handle_service_errors(func):
    def wrapper(*a, **kw):
        try: return func(*a, **kw)
        except Exception as e:
            cat = categorize(e)
            return error_result(format_error(str(e), cat), {"errorCategory": cat})
    return wrapper

Key properties:

  • Closed enum: a fixed, small set of categories.
  • Type + message inspection: both signals feed the classifier.
  • Decorator integration: the categorization is transparent to service methods.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment