app_error
Report app errors or retrieve error lists for development and debugging in Goose App Maker MCP applications.
Instructions
Report an error from the app or retrieve the list of errors.
This is useful while developing or debugging the app as it allows errors (or any messages) to be reported and monitored
Args:
error_message: Optional error message to report. If None, returns the list of errors.
clear: Optional, If True, clears the list of errors
Returns:
A string containing the list of errors if error_message is None,
otherwise a confirmation message.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| error_message | No | ||
| clear | No |
Implementation Reference
- main.py:667-715 (handler)The main handler function for the app_error tool. It reports new errors to a global list or retrieves and formats the list of existing errors. Supports clearing the list.def app_error(error_message: str = None, clear = False) -> str: """ Report an error from the app or retrieve the list of errors. This is useful while developing or debugging the app as it allows errors (or any messages) to be reported and monitored Args: error_message: Optional error message to report. If None, returns the list of errors. clear: Optional, If True, clears the list of errors Returns: A string containing the list of errors if error_message is None, otherwise a confirmation message. """ global app_errors try: # If no error message is provided, return the list of errors if error_message is None: # if app errors is empty if not app_errors: return "No errors reported. If needed, consider adding in some calls to reportError() in your app code to help with debugging." # Format the errors as a numbered list error_list = "\n".join([f"{i+1}. {err}" for i, err in enumerate(app_errors)]) if clear: app_errors.clear() return f"Reported errors:\n{error_list}" if clear: app_errors.clear() # Add the error to the list with a timestamp timestamp = time.strftime("%Y-%m-%d %H:%M:%S") app_errors.append(f"[{timestamp}] {error_message}") # Keep only the last 100 errors to prevent unbounded growth if len(app_errors) > 100: app_errors = app_errors[-100:] logger.warning(f"App error reported: {error_message}") return f"Error reported: {error_message}" except Exception as e: logger.error(f"Error handling app_error: {e}") return f"Failed to process error: {str(e)}"
- main.py:666-666 (registration)Registers the app_error function as a tool in the FastMCP server using the @mcp.tool() decorator.@mcp.tool()
- main.py:42-43 (helper)Global list used by the app_error tool to store and manage reported errors from the web app.# Global variable to store app errors app_errors = []
- main.py:667-679 (schema)Type signature and docstring defining the input parameters (error_message: str optional, clear: bool) and output (str) for the tool.def app_error(error_message: str = None, clear = False) -> str: """ Report an error from the app or retrieve the list of errors. This is useful while developing or debugging the app as it allows errors (or any messages) to be reported and monitored Args: error_message: Optional error message to report. If None, returns the list of errors. clear: Optional, If True, clears the list of errors Returns: A string containing the list of errors if error_message is None, otherwise a confirmation message. """