function::user_uint32_error - Linux


Overview

function::user_uint32_error is a command used for debugging Function-as-a-Service (FaaS) applications on Google Cloud Functions. It generates a user-defined error response with a specified HTTP status code and error message in the specified format.

Syntax

function::user_uint32_error <error-code> <error-message> [--format=FORMAT] [--file=FILE]

Options/Flags

  • --format: Specifies the format of the error message. Default is text.
    • text: Plain text error message.
    • json: JSON-formatted error message.
  • --file: Specifies the file to which the error message should be written. Default is stderr.

Examples

Generate a simple user-defined error:

function::user_uint32_error 404 "Resource not found"

Generate a JSON-formatted error and write to a file:

function::user_uint32_error 401 "Unauthorized" --format=json --file=/tmp/error.json

Common Issues

  • Make sure to specify a valid HTTP status code.
  • The error message should be within the specified format.

Integration

function::user_uint32_error can be used in conjunction with other Cloud Functions debugging commands, such as function::inspect and function::dump.

Related Commands