status.proto 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Copyright 2017 Google Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.rpc;
  16. import "google/protobuf/any.proto";
  17. option go_package = "google.golang.org/genproto/googleapis/rpc/status;status";
  18. option java_multiple_files = true;
  19. option java_outer_classname = "StatusProto";
  20. option java_package = "com.google.rpc";
  21. option objc_class_prefix = "RPC";
  22. // The `Status` type defines a logical error model that is suitable for
  23. // different programming environments, including REST APIs and RPC APIs. It is
  24. // used by [gRPC](https://github.com/grpc). The error model is designed to be:
  25. //
  26. // - Simple to use and understand for most users
  27. // - Flexible enough to meet unexpected needs
  28. //
  29. // # Overview
  30. //
  31. // The `Status` message contains three pieces of data: error code, error
  32. // message, and error details. The error code should be an enum value of
  33. // [google.rpc.Code][google.rpc.Code], but it may accept additional error codes
  34. // if needed. The error message should be a developer-facing English message
  35. // that helps developers *understand* and *resolve* the error. If a localized
  36. // user-facing error message is needed, put the localized message in the error
  37. // details or localize it in the client. The optional error details may contain
  38. // arbitrary information about the error. There is a predefined set of error
  39. // detail types in the package `google.rpc` that can be used for common error
  40. // conditions.
  41. //
  42. // # Language mapping
  43. //
  44. // The `Status` message is the logical representation of the error model, but it
  45. // is not necessarily the actual wire format. When the `Status` message is
  46. // exposed in different client libraries and different wire protocols, it can be
  47. // mapped differently. For example, it will likely be mapped to some exceptions
  48. // in Java, but more likely mapped to some error codes in C.
  49. //
  50. // # Other uses
  51. //
  52. // The error model and the `Status` message can be used in a variety of
  53. // environments, either with or without APIs, to provide a
  54. // consistent developer experience across different environments.
  55. //
  56. // Example uses of this error model include:
  57. //
  58. // - Partial errors. If a service needs to return partial errors to the client,
  59. // it may embed the `Status` in the normal response to indicate the partial
  60. // errors.
  61. //
  62. // - Workflow errors. A typical workflow has multiple steps. Each step may
  63. // have a `Status` message for error reporting.
  64. //
  65. // - Batch operations. If a client uses batch request and batch response, the
  66. // `Status` message should be used directly inside batch response, one for
  67. // each error sub-response.
  68. //
  69. // - Asynchronous operations. If an API call embeds asynchronous operation
  70. // results in its response, the status of those operations should be
  71. // represented directly using the `Status` message.
  72. //
  73. // - Logging. If some API errors are stored in logs, the message `Status` could
  74. // be used directly after any stripping needed for security/privacy reasons.
  75. message Status {
  76. // The status code, which should be an enum value of
  77. // [google.rpc.Code][google.rpc.Code].
  78. int32 code = 1;
  79. // A developer-facing error message, which should be in English. Any
  80. // user-facing error message should be localized and sent in the
  81. // [google.rpc.Status.details][google.rpc.Status.details] field, or localized
  82. // by the client.
  83. string message = 2;
  84. // A list of messages that carry the error details. There is a common set of
  85. // message types for APIs to use.
  86. repeated google.protobuf.Any details = 3;
  87. }