ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/gr2lib/trunk/gr2lib/core/exceptions/granny2apiloadexception.cs
Revision: 49
Committed: Thu Jul 15 07:39:08 2010 UTC (12 years, 1 month ago) by william
File size: 2223 byte(s)
Log Message:
implement granny2apiload exception

File Contents

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