MCPcopy Create free account
hub / github.com/cloudflare/cfssl / Wrap

Function Wrap

errors/error.go:404–438  ·  view source on GitHub ↗

Wrap returns an error that contains the given error and an error code derived from the given category, reason and the error. Currently, to avoid confusion, it is not allowed to create an error of category Success

(category Category, reason Reason, err error)

Source from the content-addressed store, hash-verified

402// the given category, reason and the error. Currently, to avoid confusion, it is not
403// allowed to create an error of category Success
404func Wrap(category Category, reason Reason, err error) *Error {
405 errorCode := int(category) + int(reason)
406 if err == nil {
407 panic("Wrap needs a supplied error to initialize.")
408 }
409
410 // do not double wrap a error
411 switch err.(type) {
412 case *Error:
413 panic("Unable to wrap a wrapped error.")
414 }
415
416 switch category {
417 case CertificateError:
418 // given VerifyFailed , report the status with more detailed status code
419 // for some certificate errors we care.
420 if reason == VerifyFailed {
421 switch errorType := err.(type) {
422 case x509.CertificateInvalidError:
423 errorCode += certificateInvalid + int(errorType.Reason)
424 case x509.UnknownAuthorityError:
425 errorCode += unknownAuthority
426 }
427 }
428 case PrivateKeyError, IntermediatesError, RootError, PolicyError, DialError,
429 APIClientError, CSRError, CTError, CertStoreError, OCSPError:
430 // no-op, just use the error
431 default:
432 panic(fmt.Sprintf("Unsupported CFSSL error type: %d.",
433 category))
434 }
435
436 return &Error{ErrorCode: errorCode, Message: err.Error()}
437
438}

Callers 13

postMethod · 0.92
authReqMethod · 0.92
getResultMapMethod · 0.92
requestMethod · 0.92
NewHandlerFunction · 0.92
HandleMethod · 0.92
NewBundlerFunction · 0.92
BundleFromFileMethod · 0.92
BundleFromRemoteMethod · 0.92
BundleMethod · 0.92
TestWrapFunction · 0.85
TestMarshalFunction · 0.85

Calls 1

ErrorMethod · 0.45

Tested by 3

TestWrapFunction · 0.68
TestMarshalFunction · 0.68
TestErrorStringFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…