Documentation
¶
Overview ¶
Package apierror renders errors in the envelope each client surface expects. Artifactory, Access, the OCI distribution API, Xray, npm and the Terraform registry all use different JSON shapes, and clients read them differently: jfrog-client-go prints the whole body after the status (only its release bundle import reads errors[0].message, and its Xray scan reads error), the Terraform providers join every errors[] entry, and Docker clients read errors[].code. One table here is the only place a shape is defined. See decision record 0002.
Index ¶
Constants ¶
const BasicChallenge = `Basic realm="Artifactory Realm"`
BasicChallenge is the WWW-Authenticate value of a 401: Artifactory's realm.
Variables ¶
var ErrNotImplemented = &Error{ Status: http.StatusNotImplemented, Code: "NOT_IMPLEMENTED", Message: "not implemented by artifactweave yet", }
ErrNotImplemented is returned by generated UnimplementedStrict stubs for operations the spec declares but no service implements yet. The strict response error handler renders it as 501 in the surface's envelope, so a scaffolded operation is visibly absent rather than a 500.
Functions ¶
Types ¶
type Error ¶
Error carries everything needed to render on any surface. Code is the OCI or Access symbolic code; Artifactory ignores it and uses Status.
func NotSupported ¶
NotSupported is the 501 answer for stubbed JFrog products. The message names artifactweave so operators reading a Terraform or jf error know the product is absent rather than broken.
type Surface ¶
type Surface int
Surface selects the error envelope. The zero value is Artifactory, which is the right default for anything under /artifactory.
const ( // Artifactory is {"errors":[{"status":404,"message":"..."}]}. Artifactory Surface = iota // Access is {"errors":[{"code":"NOT_FOUND","message":"..."}]}, used by // /access and the Projects API. Access // OCI is {"errors":[{"code":"BLOB_UNKNOWN","message":"...","detail":...}]}. OCI // Xray is {"error":"..."}; served only by the 501 stubs. Xray // NPM is {"error":"..."}; npm prints the field verbatim. NPM // TerraformRegistry is {"errors":["..."]}. TerraformRegistry // Distribution is {"status_code":404,"message":"...","errors":[{"status":404,"message":"..."}]}, // the shape JFrog Distribution documents; detail is added when set. Distribution // ArtifactoryLegacy is the Artifactory envelope plus top-level error and // message, documented for cold storage retention: // {"errors":[{"status":400,"message":"..."}],"error":"Bad Request","message":"..."}. ArtifactoryLegacy // ImportExport is the Artifactory envelope plus a top-level error that // carries the message, documented for import and export: // {"errors":[{"status":400,"message":"..."}],"error":"..."}. ImportExport // PlatformFederation is {"code":404,"message":"..."}, the HTTP status as // an integer code, used by the platform federation service (/pfed). PlatformFederation // Grid is {"code":"NOT_FOUND","message":"..."}, a symbolic code, with // details when set, used by the topology service (/grid). Grid // Text is a plain-text body, used by the Go proxy, PyPI and NuGet where // clients do not parse JSON errors. Text )