~ubuntu-branches/ubuntu/trusty/smuxi/trusty-proposed

« back to all changes in this revision

Viewing changes to lib/Newtonsoft.Json/Src/Newtonsoft.Json/JsonException.cs

  • Committer: Package Import Robot
  • Author(s): Mirco Bauer
  • Date: 2013-05-25 22:11:31 UTC
  • mfrom: (1.2.12)
  • Revision ID: package-import@ubuntu.com-20130525221131-nd2mc0kzubuwyx20
Tags: 0.8.11-1
* [22d13d5] Imported Upstream version 0.8.11
* [6d2b95a] Refreshed patches
* [89eb66e] Added ServiceStack libraries to smuxi-engine package
* [848ab10] Enable Campfire engine
* [c6dbdc7] Always build db4o for predictable build result
* [13ec489] Exclude OS X specific libraries from dh_clideps

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#region License
 
2
// Copyright (c) 2007 James Newton-King
 
3
//
 
4
// Permission is hereby granted, free of charge, to any person
 
5
// obtaining a copy of this software and associated documentation
 
6
// files (the "Software"), to deal in the Software without
 
7
// restriction, including without limitation the rights to use,
 
8
// copy, modify, merge, publish, distribute, sublicense, and/or sell
 
9
// copies of the Software, and to permit persons to whom the
 
10
// Software is furnished to do so, subject to the following
 
11
// conditions:
 
12
//
 
13
// The above copyright notice and this permission notice shall be
 
14
// included in all copies or substantial portions of the Software.
 
15
//
 
16
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
17
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 
18
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
19
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 
20
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 
21
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
22
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 
23
// OTHER DEALINGS IN THE SOFTWARE.
 
24
#endregion
 
25
 
 
26
using System;
 
27
using System.Collections.Generic;
 
28
using System.Globalization;
 
29
using System.Runtime.Serialization;
 
30
using System.Text;
 
31
using Newtonsoft.Json.Utilities;
 
32
 
 
33
namespace Newtonsoft.Json
 
34
{
 
35
  /// <summary>
 
36
  /// The exception thrown when an error occurs during Json serialization or deserialization.
 
37
  /// </summary>
 
38
#if !(SILVERLIGHT || WINDOWS_PHONE || NETFX_CORE || PORTABLE)
 
39
  [Serializable]
 
40
#endif
 
41
  public class JsonException : Exception
 
42
  {
 
43
    /// <summary>
 
44
    /// Initializes a new instance of the <see cref="JsonException"/> class.
 
45
    /// </summary>
 
46
    public JsonException()
 
47
    {
 
48
    }
 
49
 
 
50
    /// <summary>
 
51
    /// Initializes a new instance of the <see cref="JsonException"/> class
 
52
    /// with a specified error message.
 
53
    /// </summary>
 
54
    /// <param name="message">The error message that explains the reason for the exception.</param>
 
55
    public JsonException(string message)
 
56
      : base(message)
 
57
    {
 
58
    }
 
59
 
 
60
    /// <summary>
 
61
    /// Initializes a new instance of the <see cref="JsonException"/> class
 
62
    /// with a specified error message and a reference to the inner exception that is the cause of this exception.
 
63
    /// </summary>
 
64
    /// <param name="message">The error message that explains the reason for the exception.</param>
 
65
    /// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param>
 
66
    public JsonException(string message, Exception innerException)
 
67
      : base(message, innerException)
 
68
    {
 
69
    }
 
70
 
 
71
#if !(WINDOWS_PHONE || SILVERLIGHT || NETFX_CORE || PORTABLE)
 
72
    /// <summary>
 
73
    /// Initializes a new instance of the <see cref="JsonException"/> class.
 
74
    /// </summary>
 
75
    /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
 
76
    /// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
 
77
    /// <exception cref="T:System.ArgumentNullException">The <paramref name="info"/> parameter is null. </exception>
 
78
    /// <exception cref="T:System.Runtime.Serialization.SerializationException">The class name is null or <see cref="P:System.Exception.HResult"/> is zero (0). </exception>
 
79
    public JsonException(SerializationInfo info, StreamingContext context)
 
80
      : base(info, context)
 
81
    {
 
82
    }
 
83
#endif
 
84
 
 
85
    internal static string FormatExceptionMessage(IJsonLineInfo lineInfo, string path, string message)
 
86
    {
 
87
      // don't add a fullstop and space when message ends with a new line
 
88
      if (!message.EndsWith(Environment.NewLine))
 
89
      {
 
90
        message = message.Trim();
 
91
 
 
92
        if (!message.EndsWith("."))
 
93
          message += ".";
 
94
 
 
95
        message += " ";
 
96
      }
 
97
 
 
98
      message += "Path '{0}'".FormatWith(CultureInfo.InvariantCulture, path);
 
99
 
 
100
      if (lineInfo != null && lineInfo.HasLineInfo())
 
101
        message += ", line {0}, position {1}".FormatWith(CultureInfo.InvariantCulture, lineInfo.LineNumber, lineInfo.LinePosition);
 
102
 
 
103
      message += ".";
 
104
 
 
105
      return message;
 
106
    }
 
107
  }
 
108
}
 
 
b'\\ No newline at end of file'