1 |
using System; |
2 |
using System.Collections.Generic; |
3 |
using System.Text; |
4 |
using System.Windows.Forms; |
5 |
using System.Runtime.Serialization; |
6 |
|
7 |
namespace gr2lib.core.exceptions |
8 |
{ |
9 |
#region Granny2 API Load Exceptions |
10 |
|
11 |
#region public class granny2apiloadexception |
12 |
[Serializable()] |
13 |
public class granny2apiloadexception : System.Exception, ISerializable |
14 |
{ |
15 |
private const string error_message = "ERROR: Unable to load granny2 API"; |
16 |
public granny2apiloadexception() : this(new granny2dllnotfoundexception()) { } |
17 |
private granny2apiloadexception(Exception inner) : base(error_message, inner) { } |
18 |
protected granny2apiloadexception(SerializationInfo info, StreamingContext context) : base(info, context) { } |
19 |
|
20 |
public override string Message |
21 |
{ |
22 |
get |
23 |
{ |
24 |
return error_message + "\n" + |
25 |
"REASON: " + this.InnerException.Message; |
26 |
} |
27 |
} |
28 |
|
29 |
#region private class granny2dllnotfoundexception |
30 |
[Serializable()] |
31 |
private class granny2dllnotfoundexception : System.Exception, ISerializable |
32 |
{ |
33 |
public override string Message |
34 |
{ |
35 |
get |
36 |
{ |
37 |
return this.InnerException.Message + " was not found."; |
38 |
} |
39 |
} |
40 |
|
41 |
public granny2dllnotfoundexception() : this(new System.IO.FileNotFoundException(core.sharedio.granny_dll)) { } |
42 |
private granny2dllnotfoundexception(Exception inner) : base("", inner) { } |
43 |
protected granny2dllnotfoundexception(SerializationInfo info, StreamingContext context) : base(info, context) { } |
44 |
} |
45 |
#endregion |
46 |
} |
47 |
|
48 |
#endregion |
49 |
|
50 |
#region public class granny2apiloader |
51 |
public class granny2apiloader |
52 |
{ |
53 |
string application_path; |
54 |
public granny2apiloader() |
55 |
{ |
56 |
application_path = Application.StartupPath; |
57 |
|
58 |
if (!System.IO.File.Exists(core.sharedio.granny_dll)) |
59 |
{ |
60 |
throw new granny2apiloadexception(); |
61 |
} |
62 |
|
63 |
} |
64 |
} |
65 |
#endregion |
66 |
|
67 |
#endregion |
68 |
} |
69 |
|