MCPcopy
hub / github.com/prometheus/client_golang / MaybeUnwrap

Method MaybeUnwrap

prometheus/registry.go:242–251  ·  view source on GitHub ↗

MaybeUnwrap returns nil if len(errs) is 0. It returns the first and only contained error as error if len(errs is 1). In all other cases, it returns the MultiError directly. This is helpful for returning a MultiError in a way that only uses the MultiError if needed.

()

Source from the content-addressed store, hash-verified

240// the MultiError directly. This is helpful for returning a MultiError in a way
241// that only uses the MultiError if needed.
242func (errs MultiError) MaybeUnwrap() error {
243 switch len(errs) {
244 case 0:
245 return nil
246 case 1:
247 return errs[0]
248 default:
249 return errs
250 }
251}
252
253// Registry registers Prometheus collectors, collects their metrics, and gathers
254// them into MetricFamilies for exposition. It implements Registerer, Gatherer,

Callers 3

GatherMethod · 0.95
GatherMethod · 0.80
GatherMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected