//-----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation.
//
//-----------------------------------------------------------------------
namespace Microsoft.Isam.Esent.Interop
{
using System;
using System.Runtime.Serialization;
///
/// Base class for ESENT error exceptions.
///
[Serializable]
public class EsentErrorException : EsentException
{
///
/// The error code that was encountered.
///
private JET_err errorCode;
///
/// Initializes a new instance of the EsentErrorException class.
///
/// The description of the error.
/// The error code of the exception.
internal EsentErrorException(string message, JET_err err) : base(message)
{
this.errorCode = err;
}
///
/// Initializes a new instance of the EsentErrorException class. This constructor
/// is used to deserialize a serialized exception.
///
/// The data needed to deserialize the object.
/// The deserialization context.
protected EsentErrorException(SerializationInfo info, StreamingContext context) :
base(info, context)
{
this.errorCode = (JET_err)info.GetInt32("errorCode");
}
///
/// Gets the underlying Esent error for this exception.
///
public JET_err Error
{
get
{
return this.errorCode;
}
}
#if !MANAGEDESENT_ON_CORECLR // Serialization does not work in Core CLR.
/// When overridden in a derived class, sets the with information about the exception.
/// The that holds the serialized object data about the exception being thrown.
/// The that contains contextual information about the source or destination.
/// The parameter is a null reference (Nothing in Visual Basic).
/// 2
///
///
///
///
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
if (info != null)
{
info.AddValue("errorCode", this.errorCode, typeof(int));
}
}
#endif
}
}