Jan Tattermusch | a7fff86 | 2015-02-13 11:08:08 -0800 | [diff] [blame] | 1 | #region Copyright notice and license |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 2 | // Copyright 2015 gRPC authors. |
Craig Tiller | 190d360 | 2015-02-18 09:23:38 -0800 | [diff] [blame] | 3 | // |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
Craig Tiller | 190d360 | 2015-02-18 09:23:38 -0800 | [diff] [blame] | 7 | // |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
Craig Tiller | 190d360 | 2015-02-18 09:23:38 -0800 | [diff] [blame] | 9 | // |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
Jan Tattermusch | a7fff86 | 2015-02-13 11:08:08 -0800 | [diff] [blame] | 15 | #endregion |
| 16 | |
Jan Tattermusch | 66eb18d | 2015-08-09 20:03:24 -0700 | [diff] [blame] | 17 | using Grpc.Core.Utils; |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 18 | |
Jan Tattermusch | 3086862 | 2015-02-19 09:22:33 -0800 | [diff] [blame] | 19 | namespace Grpc.Core |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 20 | { |
Jan Tattermusch | 13cd125 | 2015-03-06 10:11:50 -0800 | [diff] [blame] | 21 | /// <summary> |
Jan Tattermusch | 66eb18d | 2015-08-09 20:03:24 -0700 | [diff] [blame] | 22 | /// Represents RPC result, which consists of <see cref="StatusCode"/> and an optional detail string. |
Jan Tattermusch | 13cd125 | 2015-03-06 10:11:50 -0800 | [diff] [blame] | 23 | /// </summary> |
| 24 | public struct Status |
| 25 | { |
Jan Tattermusch | a5272b6 | 2015-04-30 11:56:46 -0700 | [diff] [blame] | 26 | /// <summary> |
| 27 | /// Default result of a successful RPC. StatusCode=OK, empty details message. |
| 28 | /// </summary> |
| 29 | public static readonly Status DefaultSuccess = new Status(StatusCode.OK, ""); |
| 30 | |
Jan Tattermusch | 8c2dd9d | 2015-05-04 09:20:43 -0700 | [diff] [blame] | 31 | /// <summary> |
| 32 | /// Default result of a cancelled RPC. StatusCode=Cancelled, empty details message. |
| 33 | /// </summary> |
| 34 | public static readonly Status DefaultCancelled = new Status(StatusCode.Cancelled, ""); |
| 35 | |
Jan Tattermusch | 13cd125 | 2015-03-06 10:11:50 -0800 | [diff] [blame] | 36 | readonly StatusCode statusCode; |
| 37 | readonly string detail; |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 38 | |
Jan Tattermusch | 66eb18d | 2015-08-09 20:03:24 -0700 | [diff] [blame] | 39 | /// <summary> |
| 40 | /// Creates a new instance of <c>Status</c>. |
| 41 | /// </summary> |
| 42 | /// <param name="statusCode">Status code.</param> |
| 43 | /// <param name="detail">Detail.</param> |
Jan Tattermusch | 13cd125 | 2015-03-06 10:11:50 -0800 | [diff] [blame] | 44 | public Status(StatusCode statusCode, string detail) |
| 45 | { |
| 46 | this.statusCode = statusCode; |
| 47 | this.detail = detail; |
| 48 | } |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 49 | |
Jan Tattermusch | a29d0f3 | 2015-03-04 17:54:56 -0800 | [diff] [blame] | 50 | /// <summary> |
| 51 | /// Gets the gRPC status code. OK indicates success, all other values indicate an error. |
| 52 | /// </summary> |
Jan Tattermusch | 13cd125 | 2015-03-06 10:11:50 -0800 | [diff] [blame] | 53 | public StatusCode StatusCode |
| 54 | { |
| 55 | get |
| 56 | { |
| 57 | return statusCode; |
| 58 | } |
| 59 | } |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 60 | |
Jan Tattermusch | a29d0f3 | 2015-03-04 17:54:56 -0800 | [diff] [blame] | 61 | /// <summary> |
| 62 | /// Gets the detail. |
| 63 | /// </summary> |
Jan Tattermusch | 13cd125 | 2015-03-06 10:11:50 -0800 | [diff] [blame] | 64 | public string Detail |
| 65 | { |
| 66 | get |
| 67 | { |
| 68 | return detail; |
| 69 | } |
| 70 | } |
Jan Tattermusch | 1f18e80 | 2015-04-27 15:29:24 -0700 | [diff] [blame] | 71 | |
Jan Tattermusch | 66eb18d | 2015-08-09 20:03:24 -0700 | [diff] [blame] | 72 | /// <summary> |
| 73 | /// Returns a <see cref="System.String"/> that represents the current <see cref="Grpc.Core.Status"/>. |
| 74 | /// </summary> |
Jan Tattermusch | 1f18e80 | 2015-04-27 15:29:24 -0700 | [diff] [blame] | 75 | public override string ToString() |
| 76 | { |
| 77 | return string.Format("Status(StatusCode={0}, Detail=\"{1}\")", statusCode, detail); |
| 78 | } |
Jan Tattermusch | 13cd125 | 2015-03-06 10:11:50 -0800 | [diff] [blame] | 79 | } |
Craig Tiller | 190d360 | 2015-02-18 09:23:38 -0800 | [diff] [blame] | 80 | } |