Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add InvalidRequestException

  • Loading branch information...
commit c8299dda8198dd2ccd9fda634d641e396426bfd3 1 parent 05b7023
Hunter Morris authored December 06, 2011
65  IronSmarkets/Exceptions/InvalidRequestException.cs
... ...
@@ -0,0 +1,65 @@
  1
+// Copyright (c) 2011 Smarkets Limited
  2
+//
  3
+// Permission is hereby granted, free of charge, to any person
  4
+// obtaining a copy of this software and associated documentation
  5
+// files (the "Software"), to deal in the Software without
  6
+// restriction, including without limitation the rights to use, copy,
  7
+// modify, merge, publish, distribute, sublicense, and/or sell copies
  8
+// of the Software, and to permit persons to whom the Software is
  9
+// furnished to do so, subject to the following conditions:
  10
+//
  11
+// The above copyright notice and this permission notice shall be
  12
+// included in all copies or substantial portions of the Software.
  13
+//
  14
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  18
+// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  19
+// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  20
+// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21
+// SOFTWARE.
  22
+
  23
+using System;
  24
+using System.Collections;
  25
+using System.Collections.Generic;
  26
+using System.Linq;
  27
+
  28
+namespace IronSmarkets.Exceptions
  29
+{
  30
+    public class InvalidRequestException : Exception
  31
+    {
  32
+        private static readonly IDictionary<Proto.Seto.InvalidRequestType, string> Messages =
  33
+            new Dictionary<Proto.Seto.InvalidRequestType, string> {
  34
+            { Proto.Seto.InvalidRequestType.INVALIDREQUESTDATEOUTOFRANGE, "Date out of range" }
  35
+        };
  36
+
  37
+        private readonly string _errorMessage;
  38
+
  39
+        public string ErrorMessage { get { return _errorMessage; } }
  40
+
  41
+        private InvalidRequestException(string errorMessage)
  42
+        {
  43
+            _errorMessage = errorMessage;
  44
+        }
  45
+
  46
+        public override string Message {
  47
+            get {
  48
+                return _errorMessage;
  49
+            }
  50
+        }
  51
+
  52
+        public override IDictionary Data {
  53
+            get {
  54
+                return new Dictionary<string, object> {
  55
+                    { "ErrorMessage", ErrorMessage }
  56
+                };
  57
+            }
  58
+        }
  59
+
  60
+        internal static InvalidRequestException FromSeto(Proto.Seto.InvalidRequest seto)
  61
+        {
  62
+            return new InvalidRequestException(Messages[seto.Type]);
  63
+        }
  64
+    }
  65
+}
1  IronSmarkets/IronSmarkets.csproj
@@ -109,6 +109,7 @@
109 109
     <Compile Include="Data\Uid.cs" />
110 110
     <Compile Include="Events\IPayloadEvents.cs" />
111 111
     <Compile Include="Exceptions\ConnectionException.cs" />
  112
+    <Compile Include="Exceptions\InvalidRequestException.cs" />
112 113
     <Compile Include="Exceptions\LoginFailedException.cs" />
113 114
     <Compile Include="Exceptions\OrderInvalidException.cs" />
114 115
     <Compile Include="Exceptions\OrderRejectedException.cs" />

0 notes on commit c8299dd

Please sign in to comment.
Something went wrong with that request. Please try again.