| Index: third_party/grpc/src/csharp/Grpc.Core/RpcException.cs
|
| diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/DescriptorUtil.cs b/third_party/grpc/src/csharp/Grpc.Core/RpcException.cs
|
| similarity index 61%
|
| copy from third_party/protobuf/csharp/src/Google.Protobuf/Reflection/DescriptorUtil.cs
|
| copy to third_party/grpc/src/csharp/Grpc.Core/RpcException.cs
|
| index f5570fc40a24f9e91017280b4f6389607be6e1a7..cac417e62614ed606a1bcbc0df9940ad9a76c68b 100644
|
| --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/DescriptorUtil.cs
|
| +++ b/third_party/grpc/src/csharp/Grpc.Core/RpcException.cs
|
| @@ -1,7 +1,7 @@
|
| #region Copyright notice and license
|
| -// Protocol Buffers - Google's data interchange format
|
| -// Copyright 2008 Google Inc. All rights reserved.
|
| -// https://developers.google.com/protocol-buffers/
|
| +
|
| +// Copyright 2015, Google Inc.
|
| +// All rights reserved.
|
| //
|
| // Redistribution and use in source and binary forms, with or without
|
| // modification, are permitted provided that the following conditions are
|
| @@ -28,37 +28,48 @@
|
| // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| +
|
| #endregion
|
|
|
| -using System.Collections.Generic;
|
| -using System.Collections.ObjectModel;
|
| +using System;
|
|
|
| -namespace Google.Protobuf.Reflection
|
| +namespace Grpc.Core
|
| {
|
| /// <summary>
|
| - /// Internal class containing utility methods when working with descriptors.
|
| + /// Thrown when remote procedure call fails. Every <c>RpcException</c> is associated with a resulting <see cref="Status"/> of the call.
|
| /// </summary>
|
| - internal static class DescriptorUtil
|
| + public class RpcException : Exception
|
| {
|
| + private readonly Status status;
|
| +
|
| + /// <summary>
|
| + /// Creates a new <c>RpcException</c> associated with given status.
|
| + /// </summary>
|
| + /// <param name="status">Resulting status of a call.</param>
|
| + public RpcException(Status status) : base(status.ToString())
|
| + {
|
| + this.status = status;
|
| + }
|
| +
|
| /// <summary>
|
| - /// Equivalent to Func[TInput, int, TOutput] but usable in .NET 2.0. Only used to convert
|
| - /// arrays.
|
| + /// Creates a new <c>RpcException</c> associated with given status and message.
|
| /// </summary>
|
| - internal delegate TOutput IndexedConverter<TInput, TOutput>(TInput element, int index);
|
| + /// <param name="status">Resulting status of a call.</param>
|
| + /// <param name="message">The exception message.</param>
|
| + public RpcException(Status status, string message) : base(message)
|
| + {
|
| + this.status = status;
|
| + }
|
|
|
| /// <summary>
|
| - /// Converts the given array into a read-only list, applying the specified conversion to
|
| - /// each input element.
|
| + /// Resulting status of the call.
|
| /// </summary>
|
| - internal static IList<TOutput> ConvertAndMakeReadOnly<TInput, TOutput>
|
| - (IList<TInput> input, IndexedConverter<TInput, TOutput> converter)
|
| + public Status Status
|
| {
|
| - TOutput[] array = new TOutput[input.Count];
|
| - for (int i = 0; i < array.Length; i++)
|
| + get
|
| {
|
| - array[i] = converter(input[i], i);
|
| + return status;
|
| }
|
| - return new ReadOnlyCollection<TOutput>(array);
|
| }
|
| }
|
| -}
|
| +}
|
|
|