MCPcopy Index your code
hub / github.com/cloudflare/cfssl / New

Function New

errors/error.go:228–399  ·  view source on GitHub ↗

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

(category Category, reason Reason)

Source from the content-addressed store, hash-verified

226// the given category, reason. Currently, to avoid confusion, it is not
227// allowed to create an error of category Success
228func New(category Category, reason Reason) *Error {
229 errorCode := int(category) + int(reason)
230 var msg string
231 switch category {
232 case OCSPError:
233 switch reason {
234 case ReadFailed:
235 msg = "No certificate provided"
236 case IssuerMismatch:
237 msg = "Certificate not issued by this issuer"
238 case InvalidStatus:
239 msg = "Invalid revocation status"
240 }
241 case CertificateError:
242 switch reason {
243 case Unknown:
244 msg = "Unknown certificate error"
245 case ReadFailed:
246 msg = "Failed to read certificate"
247 case DecodeFailed:
248 msg = "Failed to decode certificate"
249 case ParseFailed:
250 msg = "Failed to parse certificate"
251 case SelfSigned:
252 msg = "Certificate is self signed"
253 case VerifyFailed:
254 msg = "Unable to verify certificate"
255 case BadRequest:
256 msg = "Invalid certificate request"
257 case MissingSerial:
258 msg = "Missing serial number in request"
259 default:
260 panic(fmt.Sprintf("Unsupported CFSSL error reason %d under category CertificateError.",
261 reason))
262
263 }
264 case PrivateKeyError:
265 switch reason {
266 case Unknown:
267 msg = "Unknown private key error"
268 case ReadFailed:
269 msg = "Failed to read private key"
270 case DecodeFailed:
271 msg = "Failed to decode private key"
272 case ParseFailed:
273 msg = "Failed to parse private key"
274 case Encrypted:
275 msg = "Private key is encrypted."
276 case NotRSAOrECCOrEd25519:
277 msg = "Private key algorithm is not RSA or ECC or Ed25519"
278 case KeyMismatch:
279 msg = "Private key does not match public key"
280 case GenerationFailed:
281 msg = "Failed to new private key"
282 case Unavailable:
283 msg = "Private key is unavailable"
284 default:
285 panic(fmt.Sprintf("Unsupported CFSSL error reason %d under category PrivateKeyError.",

Callers 15

ParsePKCS7Function · 0.92
DialFunction · 0.92
ProfileFunction · 0.92
ParseCertificateRequestFunction · 0.92
addPoliciesFunction · 0.92
remoteOpMethod · 0.92
SignMethod · 0.92
TestLintFunction · 0.92
validatorFunction · 0.92
RenewFromSignerFunction · 0.92
ParseCertificatesDERFunction · 0.92
ParseCertificatePEMFunction · 0.92

Calls

no outgoing calls

Tested by 2

TestLintFunction · 0.74
TestNewFunction · 0.56