github.com/stackdocker/rkt@v0.10.1-0.20151109095037-1aa827478248/Godeps/_workspace/src/google.golang.org/grpc/codes/codes.go (about)

     1  /*
     2   *
     3   * Copyright 2014, Google Inc.
     4   * All rights reserved.
     5   *
     6   * Redistribution and use in source and binary forms, with or without
     7   * modification, are permitted provided that the following conditions are
     8   * met:
     9   *
    10   *     * Redistributions of source code must retain the above copyright
    11   * notice, this list of conditions and the following disclaimer.
    12   *     * Redistributions in binary form must reproduce the above
    13   * copyright notice, this list of conditions and the following disclaimer
    14   * in the documentation and/or other materials provided with the
    15   * distribution.
    16   *     * Neither the name of Google Inc. nor the names of its
    17   * contributors may be used to endorse or promote products derived from
    18   * this software without specific prior written permission.
    19   *
    20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    21   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    22   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    23   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    24   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    25   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    26   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    27   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    28   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    29   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    30   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    31   *
    32   */
    33  
    34  // Package codes defines the canonical error codes used by gRPC. It is
    35  // consistent across various languages.
    36  package codes
    37  
    38  // A Code is an unsigned 32-bit error code as defined in the gRPC spec.
    39  type Code uint32
    40  
    41  //go:generate stringer -type=Code
    42  
    43  const (
    44  	// OK is returned on success.
    45  	OK Code = 0
    46  
    47  	// Canceled indicates the operation was cancelled (typically by the caller).
    48  	Canceled Code = 1
    49  
    50  	// Unknown error.  An example of where this error may be returned is
    51  	// if a Status value received from another address space belongs to
    52  	// an error-space that is not known in this address space.  Also
    53  	// errors raised by APIs that do not return enough error information
    54  	// may be converted to this error.
    55  	Unknown Code = 2
    56  
    57  	// InvalidArgument indicates client specified an invalid argument.
    58  	// Note that this differs from FailedPrecondition. It indicates arguments
    59  	// that are problematic regardless of the state of the system
    60  	// (e.g., a malformed file name).
    61  	InvalidArgument Code = 3
    62  
    63  	// DeadlineExceeded means operation expired before completion.
    64  	// For operations that change the state of the system, this error may be
    65  	// returned even if the operation has completed successfully. For
    66  	// example, a successful response from a server could have been delayed
    67  	// long enough for the deadline to expire.
    68  	DeadlineExceeded Code = 4
    69  
    70  	// NotFound means some requested entity (e.g., file or directory) was
    71  	// not found.
    72  	NotFound Code = 5
    73  
    74  	// AlreadyExists means an attempt to create an entity failed because one
    75  	// already exists.
    76  	AlreadyExists Code = 6
    77  
    78  	// PermissionDenied indicates the caller does not have permission to
    79  	// execute the specified operation. It must not be used for rejections
    80  	// caused by exhausting some resource (use ResourceExhausted
    81  	// instead for those errors).  It must not be
    82  	// used if the caller cannot be identified (use Unauthenticated
    83  	// instead for those errors).
    84  	PermissionDenied Code = 7
    85  
    86  	// Unauthenticated indicates the request does not have valid
    87  	// authentication credentials for the operation.
    88  	Unauthenticated Code = 16
    89  
    90  	// ResourceExhausted indicates some resource has been exhausted, perhaps
    91  	// a per-user quota, or perhaps the entire file system is out of space.
    92  	ResourceExhausted Code = 8
    93  
    94  	// FailedPrecondition indicates operation was rejected because the
    95  	// system is not in a state required for the operation's execution.
    96  	// For example, directory to be deleted may be non-empty, an rmdir
    97  	// operation is applied to a non-directory, etc.
    98  	//
    99  	// A litmus test that may help a service implementor in deciding
   100  	// between FailedPrecondition, Aborted, and Unavailable:
   101  	//  (a) Use Unavailable if the client can retry just the failing call.
   102  	//  (b) Use Aborted if the client should retry at a higher-level
   103  	//      (e.g., restarting a read-modify-write sequence).
   104  	//  (c) Use FailedPrecondition if the client should not retry until
   105  	//      the system state has been explicitly fixed.  E.g., if an "rmdir"
   106  	//      fails because the directory is non-empty, FailedPrecondition
   107  	//      should be returned since the client should not retry unless
   108  	//      they have first fixed up the directory by deleting files from it.
   109  	//  (d) Use FailedPrecondition if the client performs conditional
   110  	//      REST Get/Update/Delete on a resource and the resource on the
   111  	//      server does not match the condition. E.g., conflicting
   112  	//      read-modify-write on the same resource.
   113  	FailedPrecondition Code = 9
   114  
   115  	// Aborted indicates the operation was aborted, typically due to a
   116  	// concurrency issue like sequencer check failures, transaction aborts,
   117  	// etc.
   118  	//
   119  	// See litmus test above for deciding between FailedPrecondition,
   120  	// Aborted, and Unavailable.
   121  	Aborted Code = 10
   122  
   123  	// OutOfRange means operation was attempted past the valid range.
   124  	// E.g., seeking or reading past end of file.
   125  	//
   126  	// Unlike InvalidArgument, this error indicates a problem that may
   127  	// be fixed if the system state changes. For example, a 32-bit file
   128  	// system will generate InvalidArgument if asked to read at an
   129  	// offset that is not in the range [0,2^32-1], but it will generate
   130  	// OutOfRange if asked to read from an offset past the current
   131  	// file size.
   132  	//
   133  	// There is a fair bit of overlap between FailedPrecondition and
   134  	// OutOfRange.  We recommend using OutOfRange (the more specific
   135  	// error) when it applies so that callers who are iterating through
   136  	// a space can easily look for an OutOfRange error to detect when
   137  	// they are done.
   138  	OutOfRange Code = 11
   139  
   140  	// Unimplemented indicates operation is not implemented or not
   141  	// supported/enabled in this service.
   142  	Unimplemented Code = 12
   143  
   144  	// Internal errors.  Means some invariants expected by underlying
   145  	// system has been broken.  If you see one of these errors,
   146  	// something is very broken.
   147  	Internal Code = 13
   148  
   149  	// Unavailable indicates the service is currently unavailable.
   150  	// This is a most likely a transient condition and may be corrected
   151  	// by retrying with a backoff.
   152  	//
   153  	// See litmus test above for deciding between FailedPrecondition,
   154  	// Aborted, and Unavailable.
   155  	Unavailable Code = 14
   156  
   157  	// DataLoss indicates unrecoverable data loss or corruption.
   158  	DataLoss Code = 15
   159  )