// SPDX-License-Identifier: Apache-2.0 package main import ( "strings" cli "git.ipng.ch/ipng/golang-cli" ) // formatError returns a user-friendly error string. gRPC status errors are // unwrapped to show only the server's message (no "rpc error: code = ..." // boilerplate). The result is wrapped in red when color is enabled. The label() // helper and the ANSI palette now live in the golang-cli library (cli.Label, // cli.Red, ...); only this gRPC-specific unwrap stays here, wired in as // App.FormatError. func formatError(err error) string { msg := err.Error() // google.golang.org/grpc/status errors format as: // rpc error: code = desc = if i := strings.Index(msg, " desc = "); i >= 0 { msg = msg[i+len(" desc = "):] } if cli.ColorEnabled() { return cli.Red + msg + cli.Reset } return msg }