status.proto 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // Copyright (c) 2015, 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 java_multiple_files = true;
  18. option java_outer_classname = "StatusProto";
  19. option java_package = "com.google.rpc";
  20. // The `Status` type defines a logical error model that is suitable for different
  21. // programming environments, including REST APIs and RPC APIs. It is used by
  22. // [gRPC](https://github.com/grpc). The error model is designed to be:
  23. //
  24. // - Simple to use and understand for most users
  25. // - Flexible enough to meet unexpected needs
  26. //
  27. // # Overview
  28. //
  29. // The `Status` message contains three pieces of data: error code, error message,
  30. // and error details. The error code should be an enum value of
  31. // [google.rpc.Code][google.rpc.Code], but it may accept additional error codes if needed. The
  32. // error message should be a developer-facing English message that helps
  33. // developers *understand* and *resolve* the error. If a localized user-facing
  34. // error message is needed, put the localized message in the error details or
  35. // localize it in the client. The optional error details may contain arbitrary
  36. // information about the error. There is a predefined set of error detail types
  37. // in the package `google.rpc` which can be used for common error conditions.
  38. //
  39. // # Language mapping
  40. //
  41. // The `Status` message is the logical representation of the error model, but it
  42. // is not necessarily the actual wire format. When the `Status` message is
  43. // exposed in different client libraries and different wire protocols, it can be
  44. // mapped differently. For example, it will likely be mapped to some exceptions
  45. // in Java, but more likely mapped to some error codes in C.
  46. //
  47. // # Other uses
  48. //
  49. // The error model and the `Status` message can be used in a variety of
  50. // environments, either with or without APIs, to provide a
  51. // consistent developer experience across different environments.
  52. //
  53. // Example uses of this error model include:
  54. //
  55. // - Partial errors. If a service needs to return partial errors to the client,
  56. // it may embed the `Status` in the normal response to indicate the partial
  57. // errors.
  58. //
  59. // - Workflow errors. A typical workflow has multiple steps. Each step may
  60. // have a `Status` message for error reporting purpose.
  61. //
  62. // - Batch operations. If a client uses batch request and batch response, the
  63. // `Status` message should be used directly inside batch response, one for
  64. // each error sub-response.
  65. //
  66. // - Asynchronous operations. If an API call embeds asynchronous operation
  67. // results in its response, the status of those operations should be
  68. // represented directly using the `Status` message.
  69. //
  70. // - Logging. If some API errors are stored in logs, the message `Status` could
  71. // be used directly after any stripping needed for security/privacy reasons.
  72. message Status {
  73. // The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
  74. int32 code = 1;
  75. // A developer-facing error message, which should be in English. Any
  76. // user-facing error message should be localized and sent in the
  77. // [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
  78. string message = 2;
  79. // A list of messages that carry the error details. There will be a
  80. // common set of message types for APIs to use.
  81. repeated google.protobuf.Any details = 3;
  82. }