report-error will report a fatal error. It will format an error message according to the <format> string and a list of <variable>s and then write it to the standard error output; no HTTP header is output specifically for report-error.
In general, before issuing report-error, you would provide an output for the client that is appropriate. report-error's purpose is only to output a message to the standard error output, stop the processing of the current request, and move on to the next one for the service or exit if this is a command-line program; it is your responsibility to provide any meaningful output to the client prior to that.
<format> string must be present and there must be at least one <variable> (it means if you want to output a simple string literal you still have to use "%s" as format). The reason for this is to avoid formatting errors, and to use formatting in a consistent fashion.
Format
<format> string must be a literal. Variables must follow <format> separated by commas in the same order as placeholders. If you use any placeholders other than specified below, or the type of variables you use do not match the type of a corresponding placeholder in <format>, your program will error out. You can use the following placeholders in <format>:
%s for a string
%c for a number displayed as a character,
%<number>s for a string output with a width of at least <number> (any excess filled with spaces to the left),
%ld for a 64-bit signed number. Use "lo" for displaying in octal notation and "lx" for hexadecimal notation.
%<number>ld for a 64-bit signed number output with a width of at least <number> (any excess filled with spaces to the left). Use "lo" for displaying in octal notation and "lx" for hexadecimal notation.
%hd for a 32-bit signed number. Use "hu" for displaying as unsigned number, "ho" for displaying in octal notation and "hx" for hexadecimal notation.
%<number>hd for a 32-bit signed number output with a width of at least <number> (any excess filled with spaces to the left). Use "ho" for displaying as unsigned number, "ho" for displaying in octal notation and "hx" for hexadecimal notation.
%hhd for a signed 8-bit number. Use "hhu" for displaying as unsigned number, "hho" for displaying in octal notation and "hhx" for hexadecimal notation.
%<number>hhd for a number output with a width of at least <number> (any excess filled with spaces to the left). Use "hhu" for displaying as unsigned number, "hho" for displaying in octal notation and "hhx" for hexadecimal notation.
Examples
report-error"Too many input parameters for %s, encountered total of [%ld]", "customer", num_count
Copied!
Copyright (c) 2019-2025 Gliim LLC. All contents on this web site is "AS IS" without warranties or guarantees of any kind.