errdecode

package
v0.115.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeEmbeddedJSON

func DecodeEmbeddedJSON(text string) string

DecodeEmbeddedJSON scans text for an embedded JSON object (e.g. an error response body copied verbatim into an error message by an upstream library) or a bare JSON-encoded string containing Unicode escape sequences, and replaces it with a decoded, human-readable representation.

This is useful for error messages produced by libraries (such as go-git) that include a remote server's raw response body as-is, which can contain visible "\uXXXX" escape sequences instead of readable UTF-8 text when the upstream server is localized (e.g. a non-English Azure DevOps Server).

If no embedded JSON is found, or it cannot be parsed into a meaningful representation, the original text is returned unchanged.

func FormatErrorResponseBody

func FormatErrorResponseBody(body []byte) (string, string)

FormatErrorResponseBody formats the response body into a human-readable string. It returns two strings: the first is the raw body text, and the second is a structured representation of the error details if the body is in JSON format. If the body is empty or cannot be parsed, both strings will be empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL