BGC Tools
Public Types | Public Member Functions | Properties | Static Private Member Functions
LightJson.Serialization.JsonSerializationException Class Reference

The exception that is thrown when a JSON value cannot be serialized. More...

Inheritance diagram for LightJson.Serialization.JsonSerializationException:
Inheritance graph
[legend]
Collaboration diagram for LightJson.Serialization.JsonSerializationException:
Collaboration graph
[legend]

Public Types

enum  ErrorType : int { ErrorType.Unknown = 0, ErrorType.InvalidNumber, ErrorType.InvalidValueType, ErrorType.CircularReference }
 Enumerates the types of errors that can occur during serialization. More...
 

Public Member Functions

 JsonSerializationException ()
 Initializes a new instance of JsonSerializationException. More...
 
 JsonSerializationException (ErrorType type)
 Initializes a new instance of JsonSerializationException with the given error type. More...
 
 JsonSerializationException (string message, ErrorType type)
 Initializes a new instance of JsonSerializationException with the given message and error type. More...
 

Properties

ErrorType Type [get, private set]
 Gets the type of error that caused the exception to be thrown. More...
 

Static Private Member Functions

static string GetDefaultMessage (ErrorType type)
 

Detailed Description

The exception that is thrown when a JSON value cannot be serialized.

This exception is only intended to be thrown by LightJson.

Definition at line 11 of file JsonSerializationException.cs.

Member Enumeration Documentation

◆ ErrorType

Enumerates the types of errors that can occur during serialization.

Enumerator
Unknown 

Indicates that the cause of the error is unknown.

InvalidNumber 

Indicates that the writer encountered an invalid number value (NAN, infinity) during serialization.

InvalidValueType 

Indicates that the object been serialized contains an invalid JSON value type. That is, a value type that is not null, boolean, number, string, object, or array.

CircularReference 

Indicates that the object been serialized contains a circular reference.

Definition at line 63 of file JsonSerializationException.cs.

63  : int
64  {
68  Unknown = 0,
69 
73  InvalidNumber,
74 
79  InvalidValueType,
80 
84  CircularReference,
85  }

Constructor & Destructor Documentation

◆ JsonSerializationException() [1/3]

LightJson.Serialization.JsonSerializationException.JsonSerializationException ( )
inline

Initializes a new instance of JsonSerializationException.

Definition at line 21 of file JsonSerializationException.cs.

◆ JsonSerializationException() [2/3]

LightJson.Serialization.JsonSerializationException.JsonSerializationException ( ErrorType  type)
inline

Initializes a new instance of JsonSerializationException with the given error type.

Parameters
typeThe error type that describes the cause of the error.

Definition at line 28 of file JsonSerializationException.cs.

29  : this(GetDefaultMessage(type), type) { }

◆ JsonSerializationException() [3/3]

LightJson.Serialization.JsonSerializationException.JsonSerializationException ( string  message,
ErrorType  type 
)
inline

Initializes a new instance of JsonSerializationException with the given message and error type.

Parameters
messageThe message that describes the error.
typeThe error type that describes the cause of the error.

Definition at line 36 of file JsonSerializationException.cs.

37  : base(message)
38  {
39  Type = type;
40  }
ErrorType Type
Gets the type of error that caused the exception to be thrown.

Member Function Documentation

◆ GetDefaultMessage()

static string LightJson.Serialization.JsonSerializationException.GetDefaultMessage ( ErrorType  type)
inlinestaticprivate

Definition at line 42 of file JsonSerializationException.cs.

43  {
44  switch (type)
45  {
46  case ErrorType.InvalidNumber:
47  return "The value been serialized contains an invalid number value (NAN, infinity).";
48 
49  case ErrorType.InvalidValueType:
50  return "The value been serialized contains (or is) an invalid JSON type.";
51 
52  case ErrorType.CircularReference:
53  return "The value been serialized contains circular references.";
54 
55  default:
56  return "An error occurred during serialization.";
57  }
58  }

Property Documentation

◆ Type

ErrorType LightJson.Serialization.JsonSerializationException.Type
getprivate set

Gets the type of error that caused the exception to be thrown.

Definition at line 16 of file JsonSerializationException.cs.


The documentation for this class was generated from the following file: