Documentation ¶
Overview ¶
Package errors provides the error package for Kusto. It wraps all errors for Kusto. No error should be generated that doesn't come from this package. This borrows heavily fron the Upspin errors paper written by Rob Pike. See: https://commandcenter.blogspot.com/2017/12/error-handling-in-upspin.html Key differences are that we support wrapped errors and the 1.13 Unwrap/Is/As additions to the go stdlib errors package and this is tailored for Kusto and not Upspin.
Usage is simply to pass an Op, a Kind, and either a standard error to be wrapped or string that will become a string error. See examples included in the file for more details.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var Separator = ":\n\t"
Separator is the string used to separate nested errors. By default, to make errors easier on the eye, nested errors are indented on a new line. A server may instead choose to keep each error on a single line by modifying the separator string, perhaps to ":: ".
Functions ¶
func E ¶
E constructs an Error. You may pass in an Op, Kind and error. This will strip an *Error if you pass if of its Kind and Op and put it in here. It will wrap a non-*Error implementation of error. If you want to wrap the *Error in an *Error, use W(). If you pass a nil error, it panics.
Example ¶
// Wrap a non-*Error type generated from other code. There should only ever be a single // non-typed error, as all errors in Kusto should be of type *Error. That underlying error // could be a wrapped error. err := E(OpQuery, KClientInternal, io.EOF) fmt.Println(err)
Output: Op(OpQuery): Kind(KClientInternal): EOF
func ES ¶
ES constructs an Error. You may pass in an Op, Kind, string and args to the string (like fmt.Sprintf). If the result of strings.TrimSpace(s+args) == "", it panics.
Example ¶
// Create a Kusto error holding an error string. err := ES(OpQuery, KClientInternal, "some type of client error") fmt.Println(err)
Output: Op(OpQuery): Kind(KClientInternal): some type of client error
func W ¶
W wraps error outer around inner. Both must be of type *Error or this will panic.
Example ¶
// Our inner *Error. err := E(OpQuery, KClientInternal, io.EOF) // Wrap an *Error in a *Error. Can only use an error type has a concrete type of *Error. // This wraps err inside the error generated by E(). err = W(err, ES(OpQuery, KTimeout, "database db does not exist")) fmt.Println(err) /* Output: Op(OpQuery): Kind(KTimeout): database db does not exist: EOF*//
Output: Op(OpQuery): Kind(KTimeout): database db does not exist: EOF
Types ¶
type Error ¶
type Error struct { // Op is the operations that the client was trying to perform. Op Op // Kind is the error code we identify the error as. Kind Kind // Err is the wrapped internal error message. This may be of any error // type and may also wrap errors. Err error // contains filtered or unexported fields }
Error is a core error for the Kusto package.
func OneToErr ¶
OneToErr translates what we think is a Kusto OneApiError into an Error. If we don't recognize it, we return nil. This tries to wrap the internal errors, but because the errors we see don't conform to OneAPIError, I'm not sure what is going on. We shouldn't get a list of errors, but we do. We should get embedded. So I'm taking the guess that these are supposed to be wrapped errors.
type Kind ¶
type Kind uint16
Kind field classifies the error as one of a set of standard conditions.
const ( KOther Kind = 0 // Other indicates the error kind was not defined. KIO Kind = 1 // External I/O error such as network failure. KInternal Kind = 2 // Internal error or inconsistency at the server. KDBNotExist Kind = 3 // Database does not exist. KTimeout Kind = 4 // The request timed out. KLimitsExceeded Kind = 5 // The request was too large. KClientArgs Kind = 6 // The client supplied some type of arg(s) that were invalid.\ KClientInternal Kind = 7 // Internal error at the client. KHTTPError Kind = 8 // The HTTP client gave some type of error. This wraps the http library error types. )
type Op ¶
type Op uint16
Op field denotes the operation being performed.
const ( OpUnknown Op = 0 // OpUnknown indicates that the operation that caused the problem is unknown. OpQuery Op = 1 // OpQuery indicates that a Query() call is being made. OpMgmt Op = 2 // OpMgmt indicates that a Mgmt() call is being made. OpServConn Op = 3 // OpServConn indicates that the client is attempting to connect to the service. )