Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Code ¶
type Code struct {
// contains filtered or unexported fields
}
Code is the type that represents an error code. It can map to HTTP and gRPC codes. In order to properly work with custom codes or code overrides: use the RegisterCode function after creating your new Code instance.
var ( OK Code = Code{codes.OK, http.StatusOK, ""} // Unknown is the default error code. Unknown Code = Code{codes.Unknown, http.StatusInternalServerError, "Unknown"} // Internal is used when an internal error occurs. Internal Code = Code{codes.Internal, http.StatusInternalServerError, "InternalError"} // InvalidArgument is used when the client sends invalid arguments. InvalidArgument Code = Code{codes.InvalidArgument, http.StatusBadRequest, "InvalidArgument"} // NotFound is used when the requested resource is not found. NotFound Code = Code{codes.NotFound, http.StatusNotFound, "NotFound"} // AlreadyExists is used when the resource already exists. AlreadyExists Code = Code{codes.AlreadyExists, http.StatusConflict, "AlreadyExist"} // Unauthorized is used when the client is not authenticated. Unauthenticated Code = Code{codes.Unauthenticated, http.StatusUnauthorized, "Unauthenticated"} // PermissionDenied is used when the client is not authorized to perform the requested operation. PermissionDenied Code = Code{codes.PermissionDenied, http.StatusForbidden, "PermissionDenied"} )
func (Code) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface and defines how a Code should be marshaled to JSON. By default, it marshals to a string representation defined by String function.
type Errno ¶
Errno 定义了 miniblog 使用的错误类型.
func (Errno) GRPCStatus ¶
This member function is used by grpc when converting an error into a status
func (Errno) HTTPStatus ¶
func (*Errno) SetRequestID ¶
Click to show internal directories.
Click to hide internal directories.