// Code generated from semantic convention specification. DO NOT EDIT.

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package semconv // import "go.opentelemetry.io/otel/semconv/v1.41.0"

import (
	
	
	

	
)

// ErrorType returns an [attribute.KeyValue] identifying the error type of err.
//
// If err is nil, the returned attribute has the default value
// [ErrorTypeOther].
//
// If err or one of the errors in its chain has the method
//
//	ErrorType() string
//
// the returned attribute has that method's return value. If multiple errors in
// the chain implement this method, the value from the first match found by
// [errors.As] is used. Otherwise, the returned attribute has a value derived
// from the concrete type of err after unwrapping any wrappers created with
// [fmt.Errorf].
//
// The key of the returned attribute is [ErrorTypeKey].
func ( error) attribute.KeyValue {
	if  == nil {
		return ErrorTypeOther
	}

	return ErrorTypeKey.String(errorType())
}

func ( error) string {
	var  string
	if ,  := .(interface{ () string });  {
		// Fast path: check the top-level error first.
		 = .()
	} else {
		// Fallback: search the error chain for an ErrorType method.
		var  interface{ () string }
		if errors.As(, &) {
			// Prioritize the ErrorType method if available.
			 = .()
		}
	}
	if  == "" {
		// Fallback to reflection if the ErrorType method is not supported or
		// returns an empty value.

		 := reflect.TypeOf(unwrapFmtWrapped())
		,  := .PkgPath(), .Name()
		if  != "" &&  != "" {
			 =  + "." + 
		} else {
			// The type has no package path or name (predeclared, not-defined,
			// or alias for a not-defined type).
			//
			// This is not guaranteed to be unique, but is a best effort.
			 = .String()
		}
	}
	return 
}

var fmtWrapErrorType = reflect.TypeOf(fmt.Errorf("wrapped: %w", errors.New("err")))

func ( error) error {
	for reflect.TypeOf() == fmtWrapErrorType {
		 := errors.Unwrap()
		if  == nil {
			return  // When the wrapped error is nil, use the concrete type of the wrapper.
		}
		 = 
	}
	return 
}