-
Notifications
You must be signed in to change notification settings - Fork 934
/
Copy pathObjectNotFoundException.cs
76 lines (69 loc) · 2.62 KB
/
ObjectNotFoundException.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System;
using System.Runtime.Serialization;
namespace NHibernate
{
/// <summary>
/// Thrown when <c>ISession.Load()</c> fails to select a row with
/// the given primary key (identifier value). This exception might not
/// be thrown when <c>Load()</c> is called, even if there was no
/// row on the database, because <c>Load()</c> returns a proxy if
/// possible. Applications should use <c>ISession.Get()</c> to test if
/// a row exists in the database.
/// </summary>
[Serializable]
public class ObjectNotFoundException : UnresolvableObjectException
{
/// <summary>
/// Initializes a new instance of the <see cref="ObjectNotFoundException"/> class.
/// </summary>
public ObjectNotFoundException( ) : base( "No object could be found with the supplied identifier.", null, null )
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ObjectNotFoundException"/> class.
/// </summary>
/// <param name="identifier">The identifier of the object that was attempting to be loaded.</param>
/// <param name="type">The <see cref="System.Type"/> that NHibernate was trying to find a row for in the database.</param>
public ObjectNotFoundException( object identifier, System.Type type ) : base( identifier, type )
{
}
public static new void ThrowIfNull( object o, object id, System.Type clazz )
{
if( o == null )
{
throw new ObjectNotFoundException( id, clazz );
}
}
#region ISerializable Members
/// <summary>
/// Initializes a new instance of the <see cref="ObjectNotFoundException"/> class
/// with serialized data.
/// </summary>
/// <param name="info">
/// The <see cref="SerializationInfo"/> that holds the serialized object
/// data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="StreamingContext"/> that contains contextual information about the source or destination.
/// </param>
protected ObjectNotFoundException( SerializationInfo info, StreamingContext context ) : base( info, context )
{
}
/// <summary>
/// Sets the serialization info for <see cref="ObjectNotFoundException"/> after
/// getting the info from the base Exception.
/// </summary>
/// <param name="info">
/// The <see cref="SerializationInfo"/> that holds the serialized object
/// data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="StreamingContext"/> that contains contextual information about the source or destination.
/// </param>
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData( info, context );
}
#endregion
}
}