{"modulePath":"github.com/unitytech/client-go","version":"v2.0.0+incompatible","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package runtime\n\n## Variables\n\n```go\nvar ErrorHandlers = []func(error){\n\tlogError,\n\t(\u0026rudimentaryErrorBackoff{\n\t\tlastErrorTime: time.Now(),\n\n\t\tminPeriod: time.Millisecond,\n\t}).OnError,\n}\n```\nErrorHandlers is a list of functions which will be invoked when an unreturnable error occurs. TODO(lavalamp): for testability, this and the below HandleError function should be packaged up into a testable and reusable object.\n\n```go\nvar PanicHandlers = []func(interface{}){logPanic}\n```\nPanicHandlers is a list of functions which will be invoked when a panic happens.\n\n```go\nvar (\n\t// ReallyCrash controls the behavior of HandleCrash and now defaults\n\t// true. It's still exposed so components can optionally set to false\n\t// to restore prior behavior.\n\tReallyCrash = true\n)\n```\n\n## Functions\n\n```go\nfunc GetCaller() string\n```\nGetCaller returns the caller of the function that calls it.\n\n```go\nfunc HandleCrash(additionalHandlers ...func(interface{}))\n```\nHandleCrash simply catches a crash and logs an error. Meant to be called via defer.  Additional context-specific handlers can be provided, and will be called in case of panic.  HandleCrash actually crashes, after calling the handlers and logging the panic message.\n\nTODO: remove this function. We are switching to a world where it's safe for apiserver to panic, since it will be restarted by kubelet. At the beginning of the Kubernetes project, nothing was going to restart apiserver and so catching panics was important. But it's actually much simpler for montoring software if we just exit when an unexpected panic happens.\n\n```go\nfunc HandleError(err error)\n```\nHandlerError is a method to invoke when a non-user facing piece of code cannot return an error and needs to indicate it has been ignored. Invoking this method is preferable to logging the error - the default behavior is to log but the errors may be sent to a remote server for analysis.\n\n```go\nfunc RecoverFromPanic(err *error)\n```\nRecoverFromPanic replaces the specified error with an error containing the original error, and  the call tree when a panic occurs. This enables error handlers to handle errors and panics the same way.\n\n","path":"github.com/unitytech/client-go/pkg/util/runtime","name":"runtime","synopsis":"","isRedistributable":true}
