You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-07-15 01:04:25 +02:00
Add ErrorHandlerFunc to simplify creating ErrorHandlers (#2149)
* Add ErrorHandlerFunc to simplify creating ErrorHandlers * Add CHANGELOG entry * Apply suggestions from code review Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com> * Add interface assertion Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
23cb939611
commit
21d4686f4f
@ -25,3 +25,14 @@ type ErrorHandler interface {
|
||||
// DO NOT CHANGE: any modification will not be backwards compatible and
|
||||
// must never be done outside of a new major release.
|
||||
}
|
||||
|
||||
// ErrorHandlerFunc is a convenience adapter to allow the use of a function
|
||||
// as an ErrorHandler.
|
||||
type ErrorHandlerFunc func(error)
|
||||
|
||||
var _ ErrorHandler = ErrorHandlerFunc(nil)
|
||||
|
||||
// Handle handles the irremediable error by calling the ErrorHandlerFunc itself.
|
||||
func (f ErrorHandlerFunc) Handle(err error) {
|
||||
f(err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user