2002-08-23 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / class / corlib / System.IO / FileLoadException.cs
1 //
2 // System.IO.FileLoadException.cs
3 //
4 // Author:
5 //   Paolo Molaro (lupus@ximian.com)
6 //   Duncan Mak (duncan@ximian.com)
7 //
8 // (C) 2001 Ximian, Inc.  http://www.ximian.com
9 //
10
11 using System.Globalization;
12 using System.IO;
13 using System.Runtime.Serialization;
14
15 namespace System.IO {
16         [Serializable]
17         public class FileLoadException : IOException {
18
19                 // Fields
20                 string msg;
21                 Exception inner;
22                 string fileName;
23                 string fusionLog;
24                 
25                 // Constructors
26                 public FileLoadException ()
27                         : base (Locale.GetText ("I/O Error"))
28                 {
29                         msg = Locale.GetText ("I/O Error");
30                 }
31
32                 public FileLoadException (string message)
33                         : base (message)
34                 {
35                         msg = message;
36                 }
37
38                 public FileLoadException (string message, string fileName)
39                         : base (message)
40                 {
41                         this.msg = message;
42                         this.fileName = fileName;
43                 }               
44
45                 public FileLoadException (string message, Exception inner)
46                         : base (message, inner)
47                 {
48                         msg = message;
49                         this.inner = inner;
50                 }
51
52                 public FileLoadException (string message, string fileName, Exception inner)
53                         : base (message, inner)
54                 {
55                         this.msg = message;
56                         this.fileName = fileName;
57                         this.inner = inner;
58                 }
59
60                 protected FileLoadException (SerializationInfo info, StreamingContext context)
61                 {
62                         fileName = info.GetString ("FileLoad_FileName");
63                         fusionLog = info.GetString ("FileLoad_FusionLog");
64                 }
65
66                 // Properties
67                 public override string Message
68                 {
69                         get {
70                                 if (fileName != null)
71                                         return Locale.GetText (msg + ": " + fileName);
72                                 else
73                                         return msg;
74                         }
75                 }
76
77                 public string FileName
78                 {
79                         get { return fileName; }
80                 }
81                 
82                 public string FusionLog
83                 {
84                         get { return fusionLog; }
85                 }
86
87                 // Methods
88                 public override void GetObjectData (SerializationInfo info, StreamingContext context)
89                 {
90                         base.GetObjectData (info, context);
91                         info.AddValue ("FileLoad_FileName", fileName);
92                         info.AddValue ("FileLoad_FusionLog", fusionLog);
93                 }
94
95                 public override string ToString ()
96                 {
97                         string result = GetType ().FullName + ": " + Message;
98                         if (this.InnerException != null)
99                                 result +=" ----> " + InnerException;
100                         if (this.StackTrace != null)
101                                 result += '\n' + StackTrace;
102
103                         return result;
104                 }
105         }
106 }