• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang errcode.Register函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/docker/distribution/registry/api/errcode.Register函数的典型用法代码示例。如果您正苦于以下问题:Golang Register函数的具体用法?Golang Register怎么用?Golang Register使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Register函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1:

// This file contains all of the errors that can be generated from the
// docker/daemon component.

import (
	"net/http"

	"github.com/docker/distribution/registry/api/errcode"
)

var (
	// ErrorCodeNoSuchContainer is generated when we look for a container by
	// name or ID and we can't find it.
	ErrorCodeNoSuchContainer = errcode.Register(errGroup, errcode.ErrorDescriptor{
		Value:          "NOSUCHCONTAINER",
		Message:        "No such container: %s",
		Description:    "The specified container can not be found",
		HTTPStatusCode: http.StatusNotFound,
	})

	// ErrorCodeUnregisteredContainer is generated when we try to load
	// a storage driver for an unregistered container
	ErrorCodeUnregisteredContainer = errcode.Register(errGroup, errcode.ErrorDescriptor{
		Value:          "UNREGISTEREDCONTAINER",
		Message:        "Can't load storage driver for unregistered container %s",
		Description:    "An attempt was made to load the storage driver for a container that is not registered with the daemon",
		HTTPStatusCode: http.StatusInternalServerError,
	})

	// ErrorCodeContainerBeingRemoved is generated when an attempt to start
	// a container is made but its in the process of being removed, or is dead.
	ErrorCodeContainerBeingRemoved = errcode.Register(errGroup, errcode.ErrorDescriptor{
开发者ID:Neverous,项目名称:other-docker,代码行数:31,代码来源:daemon.go


示例2:

package errors

import "github.com/docker/distribution/registry/api/errcode"

var (
	// StoreKeyNotFound is an error returned by the API when the requested key is not found in the store
	StoreKeyNotFound = errcode.Register("store", errcode.ErrorDescriptor{
		Value:       "KEYNOTFOUND",
		Message:     "Key not found in store",
		Description: "Key does not exist in the K/V store",
	})

	// StoreKeyModified is an error returned by the API when the key was modified during an atomic operation
	StoreKeyModified = errcode.Register("store", errcode.ErrorDescriptor{
		Value:       "KEYMODIFIED",
		Message:     "Unable to complete atomic operation, key modified",
		Description: "Key was modified while operation was being performed",
	})
)
开发者ID:cpuguy83,项目名称:drax,代码行数:19,代码来源:register.go


示例3:

import (
	"net/http"

	"github.com/docker/distribution/registry/api/errcode"
)

const errGroup = "registry.api.v2"

var (
	// ErrorCodeDigestInvalid is returned when uploading a blob if the
	// provided digest does not match the blob contents.
	ErrorCodeDigestInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
		Value:   "DIGEST_INVALID",
		Message: "provided digest did not match uploaded content",
		Description: `When a blob is uploaded, the registry will check that
		the content matches the digest provided by the client. The error may
		include a detail structure with the key "digest", including the
		invalid digest string. This error may also be returned when a manifest
		includes an invalid layer digest.`,
		HTTPStatusCode: http.StatusBadRequest,
	})

	// ErrorCodeSizeInvalid is returned when uploading a blob if the provided
	ErrorCodeSizeInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
		Value:   "SIZE_INVALID",
		Message: "provided length did not match content length",
		Description: `When a layer is uploaded, the provided size will be
		checked against the uploaded content. If they do not match, this error
		will be returned.`,
		HTTPStatusCode: http.StatusBadRequest,
	})
开发者ID:CadeLaRen,项目名称:docker-3,代码行数:31,代码来源:errors.go


示例4:

package errors

import (
	"net/http"

	"github.com/docker/distribution/registry/api/errcode"
)

var (
	// ErrorCodeNewerClientVersion is generated when a request from a client
	// specifies a higher version than the server supports.
	ErrorCodeNewerClientVersion = errcode.Register(errGroup, errcode.ErrorDescriptor{
		Value:          "NEWERCLIENTVERSION",
		Message:        "client is newer than server (client API version: %s, server API version: %s)",
		Description:    "The client version is higher than the server version",
		HTTPStatusCode: http.StatusBadRequest,
	})

	// ErrorCodeOldClientVersion is generated when a request from a client
	// specifies a version lower than the minimum version supported by the server.
	ErrorCodeOldClientVersion = errcode.Register(errGroup, errcode.ErrorDescriptor{
		Value:          "OLDCLIENTVERSION",
		Message:        "client version %s is too old. Minimum supported API version is %s, please upgrade your client to a newer version",
		Description:    "The client version is too old for the server",
		HTTPStatusCode: http.StatusBadRequest,
	})

	// ErrorNetworkControllerNotEnabled is generated when the networking stack in not enabled
	// for certain platforms, like windows.
	ErrorNetworkControllerNotEnabled = errcode.Register(errGroup, errcode.ErrorDescriptor{
		Value:          "NETWORK_CONTROLLER_NOT_ENABLED",
开发者ID:pirater,项目名称:os,代码行数:31,代码来源:server.go


示例5:

package errors

// This file contains all of the errors that can be generated from the
// docker/daemon component.

import (
	"net/http"

	"github.com/docker/distribution/registry/api/errcode"
)

var (
	// ErrorCodeNoSuchContainer is generated when we look for a container by
	// name or ID and we can't find it.
	ErrorCodeNoSuchContainer = errcode.Register(errGroup, errcode.ErrorDescriptor{
		Value:          "NOSUCHCONTAINER",
		Message:        "no such id: %s",
		Description:    "The specified container can not be found",
		HTTPStatusCode: http.StatusNotFound,
	})
)
开发者ID:francisbouvier,项目名称:docker,代码行数:21,代码来源:daemon.go


示例6:

// This file contains all of the errors that can be generated from the
// docker/daemon component.

import (
	"net/http"

	"github.com/docker/distribution/registry/api/errcode"
)

var (
	// ErrorCodeNoSuchContainer is generated when we look for a container by
	// name or ID and we can't find it.
	ErrorCodeNoSuchContainer = errcode.Register(errGroup, errcode.ErrorDescriptor{
		Value:          "NOSUCHCONTAINER",
		Message:        "no such id: %s",
		Description:    "The specified container can not be found",
		HTTPStatusCode: http.StatusNotFound,
	})

	// ErrorCodeUnregisteredContainer is generated when we try to load
	// a storage driver for an unregistered container
	ErrorCodeUnregisteredContainer = errcode.Register(errGroup, errcode.ErrorDescriptor{
		Value:          "UNREGISTEREDCONTAINER",
		Message:        "Can't load storage driver for unregistered container %s",
		HTTPStatusCode: http.StatusInternalServerError,
	})

	// ErrorCodeContainerBeingRemoved is generated when an attempt to start
	// a container is made but its in the process of being removed, or is dead.
	ErrorCodeContainerBeingRemoved = errcode.Register(errGroup, errcode.ErrorDescriptor{
		Value:          "CONTAINERBEINGREMOVED",
开发者ID:waterytowers,项目名称:global-hack-day-3,代码行数:31,代码来源:daemon.go


示例7:

	"net/http"

	"github.com/docker/distribution/registry/api/errcode"
)

// The notary API is on version 1, but URLs start with /v2/ to be consistent
// with the registry API
const errGroup = "notary.api.v1"

// These errors should be returned from contextHandlers only. They are
// serialized and returned to a user as part of the generic error handling
// done by the rootHandler
var (
	ErrNoStorage = errcode.Register(errGroup, errcode.ErrorDescriptor{
		Value:          "NO_STORAGE",
		Message:        "The server is misconfigured and has no storage.",
		Description:    "No storage backend has been configured for the server.",
		HTTPStatusCode: http.StatusInternalServerError,
	})
	ErrNoFilename = errcode.Register(errGroup, errcode.ErrorDescriptor{
		Value:          "NO_FILENAME",
		Message:        "No file/role name provided.",
		Description:    "No file/role name is provided to associate an update with.",
		HTTPStatusCode: http.StatusBadRequest,
	})
	ErrInvalidRole = errcode.Register(errGroup, errcode.ErrorDescriptor{
		Value:          "INVALID_ROLE",
		Message:        "The role you are attempting to operate on is invalid.",
		Description:    "The user attempted to operate on a role that is not deemed valid.",
		HTTPStatusCode: http.StatusBadRequest,
	})
	ErrMalformedJSON = errcode.Register(errGroup, errcode.ErrorDescriptor{
开发者ID:useidel,项目名称:notary,代码行数:32,代码来源:errors.go


示例8:

package errors

import (
	"net/http"

	"github.com/docker/distribution/registry/api/errcode"
)

var (
	// ErrorCodeNewerClientVersion is generated when a request from a client
	// specifies a higher version than the server supports.
	ErrorCodeNewerClientVersion = errcode.Register(errGroup, errcode.ErrorDescriptor{
		Value:          "NEWERCLIENTVERSION",
		Message:        "client is newer than server (client API version: %s, server API version: %s)",
		Description:    "The client version is higher than the server version",
		HTTPStatusCode: http.StatusBadRequest,
	})

	// ErrorCodeOldClientVersion is generated when a request from a client
	// specifies a version lower than the minimum version supported by the server.
	ErrorCodeOldClientVersion = errcode.Register(errGroup, errcode.ErrorDescriptor{
		Value:          "OLDCLIENTVERSION",
		Message:        "client version %s is too old. Minimum supported API version is %s, please upgrade your client to a newer version",
		Description:    "The client version is too old for the server",
		HTTPStatusCode: http.StatusBadRequest,
	})
)
开发者ID:newdeamon,项目名称:docker,代码行数:27,代码来源:server.go


示例9:

package errors

// This file contains all of the errors that can be generated from the
// docker/image component.

import (
	"net/http"

	"github.com/docker/distribution/registry/api/errcode"
)

var (
	// ErrorCodeInvalidImageID is generated when image id specified is incorrectly formatted.
	ErrorCodeInvalidImageID = errcode.Register(errGroup, errcode.ErrorDescriptor{
		Value:          "INVALIDIMAGEID",
		Message:        "image ID '%s' is invalid ",
		Description:    "The specified image id is incorrectly formatted",
		HTTPStatusCode: http.StatusInternalServerError,
	})
)
开发者ID:DaveDaCoda,项目名称:docker,代码行数:20,代码来源:image.go


示例10:

package main

import (
	"net/http"

	"github.com/docker/distribution/registry/api/errcode"
)

var (
	errGroup = "tokenserver"

	// ErrorBadTokenOption is returned when a token parameter is invalid
	ErrorBadTokenOption = errcode.Register(errGroup, errcode.ErrorDescriptor{
		Value:   "BAD_TOKEN_OPTION",
		Message: "bad token option",
		Description: `This error may be returned when a request for a
		token contains an option which is not valid`,
		HTTPStatusCode: http.StatusBadRequest,
	})

	// ErrorMissingRequiredField is returned when a required form field is missing
	ErrorMissingRequiredField = errcode.Register(errGroup, errcode.ErrorDescriptor{
		Value:   "MISSING_REQUIRED_FIELD",
		Message: "missing required field",
		Description: `This error may be returned when a request for a
		token does not contain a required form field`,
		HTTPStatusCode: http.StatusBadRequest,
	})

	// ErrorUnsupportedValue is returned when a form field has an unsupported value
	ErrorUnsupportedValue = errcode.Register(errGroup, errcode.ErrorDescriptor{
开发者ID:CowLeo,项目名称:distribution,代码行数:31,代码来源:errors.go


示例11:

// This file contains all of the errors that can be generated from the
// docker/builder component.

import (
	"net/http"

	"github.com/docker/distribution/registry/api/errcode"
)

var (
	// ErrorCodeAtLeastOneArg is generated when the parser comes across a
	// Dockerfile command that doesn't have any args.
	ErrorCodeAtLeastOneArg = errcode.Register(errGroup, errcode.ErrorDescriptor{
		Value:          "ATLEASTONEARG",
		Message:        "%s requires at least one argument",
		Description:    "The specified command requires at least one argument",
		HTTPStatusCode: http.StatusInternalServerError,
	})

	// ErrorCodeExactlyOneArg is generated when the parser comes across a
	// Dockerfile command that requires exactly one arg but got less/more.
	ErrorCodeExactlyOneArg = errcode.Register(errGroup, errcode.ErrorDescriptor{
		Value:          "EXACTLYONEARG",
		Message:        "%s requires exactly one argument",
		Description:    "The specified command requires exactly one argument",
		HTTPStatusCode: http.StatusInternalServerError,
	})

	// ErrorCodeAtLeastTwoArgs is generated when the parser comes across a
	// Dockerfile command that requires at least two args but got less.
	ErrorCodeAtLeastTwoArgs = errcode.Register(errGroup, errcode.ErrorDescriptor{
开发者ID:DaveDaCoda,项目名称:docker,代码行数:31,代码来源:builder.go


示例12:

package errors

// This file contains all of the errors that can be generated from the
// docker/network component.

import (
	"net/http"

	"github.com/docker/distribution/registry/api/errcode"
)

var (
	// ErrorCodeNetworkAlreadyExists is generated when trying to create a
	// network with a name that's already registered.
	ErrorCodeNetworkAlreadyExists = errcode.Register(errGroup, errcode.ErrorDescriptor{
		Value:          "NETWORKALREADYEXISTS",
		Message:        "network with name %s already exists",
		Description:    "The specified network name already exists",
		HTTPStatusCode: http.StatusConflict,
	})
)
开发者ID:leobcn,项目名称:docker,代码行数:21,代码来源:network.go



注:本文中的github.com/docker/distribution/registry/api/errcode.Register函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang errcode.ServeJSON函数代码示例发布时间:2022-05-23
下一篇:
Golang reference.NamedTagged类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap