Exceptions.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. // Exceptions.cs
  2. // ------------------------------------------------------------------
  3. //
  4. // Copyright (c) 2008, 2009 Dino Chiesa and Microsoft Corporation.
  5. // All rights reserved.
  6. //
  7. // This code module is part of DotNetZip, a zipfile class library.
  8. //
  9. // ------------------------------------------------------------------
  10. //
  11. // This code is licensed under the Microsoft Public License.
  12. // See the file License.txt for the license details.
  13. // More info on: http://dotnetzip.codeplex.com
  14. //
  15. // ------------------------------------------------------------------
  16. //
  17. // last saved (in emacs):
  18. // Time-stamp: <2011-July-12 12:19:10>
  19. //
  20. // ------------------------------------------------------------------
  21. //
  22. // This module defines exceptions used in the class library.
  23. //
  24. using System;
  25. using System.Collections.Generic;
  26. using System.Text;
  27. #if !NETCF
  28. using System.Runtime.Serialization;
  29. #endif
  30. namespace Ionic.Zip
  31. {
  32. ///// <summary>
  33. ///// Base exception type for all custom exceptions in the Zip library. It acts as a marker class.
  34. ///// </summary>
  35. //[AttributeUsage(AttributeTargets.Class)]
  36. //public class ZipExceptionAttribute : Attribute { }
  37. /// <summary>
  38. /// Issued when an <c>ZipEntry.ExtractWithPassword()</c> method is invoked
  39. /// with an incorrect password.
  40. /// </summary>
  41. #if !SILVERLIGHT
  42. [Serializable]
  43. #endif
  44. [System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d0000B")]
  45. public class BadPasswordException : ZipException
  46. {
  47. /// <summary>
  48. /// Default ctor.
  49. /// </summary>
  50. public BadPasswordException() { }
  51. /// <summary>
  52. /// Come on, you know how exceptions work. Why are you looking at this documentation?
  53. /// </summary>
  54. /// <param name="message">The message in the exception.</param>
  55. public BadPasswordException(String message)
  56. : base(message)
  57. { }
  58. /// <summary>
  59. /// Come on, you know how exceptions work. Why are you looking at this documentation?
  60. /// </summary>
  61. /// <param name="message">The message in the exception.</param>
  62. /// <param name="innerException">The innerException for this exception.</param>
  63. public BadPasswordException(String message, Exception innerException)
  64. : base(message, innerException)
  65. {
  66. }
  67. #if ! (NETCF || SILVERLIGHT)
  68. /// <summary>
  69. /// Come on, you know how exceptions work. Why are you looking at this documentation?
  70. /// </summary>
  71. /// <param name="info">The serialization info for the exception.</param>
  72. /// <param name="context">The streaming context from which to deserialize.</param>
  73. protected BadPasswordException(SerializationInfo info, StreamingContext context)
  74. : base(info, context)
  75. { }
  76. #endif
  77. }
  78. /// <summary>
  79. /// Indicates that a read was attempted on a stream, and bad or incomplete data was
  80. /// received.
  81. /// </summary>
  82. #if !SILVERLIGHT
  83. [Serializable]
  84. #endif
  85. [System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d0000A")]
  86. public class BadReadException : ZipException
  87. {
  88. /// <summary>
  89. /// Default ctor.
  90. /// </summary>
  91. public BadReadException() { }
  92. /// <summary>
  93. /// Come on, you know how exceptions work. Why are you looking at this documentation?
  94. /// </summary>
  95. /// <param name="message">The message in the exception.</param>
  96. public BadReadException(String message)
  97. : base(message)
  98. { }
  99. /// <summary>
  100. /// Come on, you know how exceptions work. Why are you looking at this documentation?
  101. /// </summary>
  102. /// <param name="message">The message in the exception.</param>
  103. /// <param name="innerException">The innerException for this exception.</param>
  104. public BadReadException(String message, Exception innerException)
  105. : base(message, innerException)
  106. {
  107. }
  108. #if ! (NETCF || SILVERLIGHT)
  109. /// <summary>
  110. /// Come on, you know how exceptions work. Why are you looking at this documentation?
  111. /// </summary>
  112. /// <param name="info">The serialization info for the exception.</param>
  113. /// <param name="context">The streaming context from which to deserialize.</param>
  114. protected BadReadException(SerializationInfo info, StreamingContext context)
  115. : base(info, context)
  116. { }
  117. #endif
  118. }
  119. /// <summary>
  120. /// Issued when an CRC check fails upon extracting an entry from a zip archive.
  121. /// </summary>
  122. #if !SILVERLIGHT
  123. [Serializable]
  124. #endif
  125. [System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d00009")]
  126. public class BadCrcException : ZipException
  127. {
  128. /// <summary>
  129. /// Default ctor.
  130. /// </summary>
  131. public BadCrcException() { }
  132. /// <summary>
  133. /// Come on, you know how exceptions work. Why are you looking at this documentation?
  134. /// </summary>
  135. /// <param name="message">The message in the exception.</param>
  136. public BadCrcException(String message)
  137. : base(message)
  138. { }
  139. #if ! (NETCF || SILVERLIGHT)
  140. /// <summary>
  141. /// Come on, you know how exceptions work. Why are you looking at this documentation?
  142. /// </summary>
  143. /// <param name="info">The serialization info for the exception.</param>
  144. /// <param name="context">The streaming context from which to deserialize.</param>
  145. protected BadCrcException(SerializationInfo info, StreamingContext context)
  146. : base(info, context)
  147. { }
  148. #endif
  149. }
  150. /// <summary>
  151. /// Issued when errors occur saving a self-extracting archive.
  152. /// </summary>
  153. #if !SILVERLIGHT
  154. [Serializable]
  155. #endif
  156. [System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d00008")]
  157. public class SfxGenerationException : ZipException
  158. {
  159. /// <summary>
  160. /// Default ctor.
  161. /// </summary>
  162. public SfxGenerationException() { }
  163. /// <summary>
  164. /// Come on, you know how exceptions work. Why are you looking at this documentation?
  165. /// </summary>
  166. /// <param name="message">The message in the exception.</param>
  167. public SfxGenerationException(String message)
  168. : base(message)
  169. { }
  170. #if ! (NETCF || SILVERLIGHT)
  171. /// <summary>
  172. /// Come on, you know how exceptions work. Why are you looking at this documentation?
  173. /// </summary>
  174. /// <param name="info">The serialization info for the exception.</param>
  175. /// <param name="context">The streaming context from which to deserialize.</param>
  176. protected SfxGenerationException(SerializationInfo info, StreamingContext context)
  177. : base(info, context)
  178. { }
  179. #endif
  180. }
  181. /// <summary>
  182. /// Indicates that an operation was attempted on a ZipFile which was not possible
  183. /// given the state of the instance. For example, if you call <c>Save()</c> on a ZipFile
  184. /// which has no filename set, you can get this exception.
  185. /// </summary>
  186. #if !SILVERLIGHT
  187. [Serializable]
  188. #endif
  189. [System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d00007")]
  190. public class BadStateException : ZipException
  191. {
  192. /// <summary>
  193. /// Default ctor.
  194. /// </summary>
  195. public BadStateException() { }
  196. /// <summary>
  197. /// Come on, you know how exceptions work. Why are you looking at this documentation?
  198. /// </summary>
  199. /// <param name="message">The message in the exception.</param>
  200. public BadStateException(String message)
  201. : base(message)
  202. { }
  203. /// <summary>
  204. /// Come on, you know how exceptions work. Why are you looking at this documentation?
  205. /// </summary>
  206. /// <param name="message">The message in the exception.</param>
  207. /// <param name="innerException">The innerException for this exception.</param>
  208. public BadStateException(String message, Exception innerException)
  209. : base(message, innerException)
  210. {}
  211. #if ! (NETCF || SILVERLIGHT)
  212. /// <summary>
  213. /// Come on, you know how exceptions work. Why are you looking at this documentation?
  214. /// </summary>
  215. /// <param name="info">The serialization info for the exception.</param>
  216. /// <param name="context">The streaming context from which to deserialize.</param>
  217. protected BadStateException(SerializationInfo info, StreamingContext context)
  218. : base(info, context)
  219. { }
  220. #endif
  221. }
  222. /// <summary>
  223. /// Base class for all exceptions defined by and throw by the Zip library.
  224. /// </summary>
  225. #if !SILVERLIGHT
  226. [Serializable]
  227. #endif
  228. [System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d00006")]
  229. public class ZipException : Exception
  230. {
  231. /// <summary>
  232. /// Default ctor.
  233. /// </summary>
  234. public ZipException() { }
  235. /// <summary>
  236. /// Come on, you know how exceptions work. Why are you looking at this documentation?
  237. /// </summary>
  238. /// <param name="message">The message in the exception.</param>
  239. public ZipException(String message) : base(message) { }
  240. /// <summary>
  241. /// Come on, you know how exceptions work. Why are you looking at this documentation?
  242. /// </summary>
  243. /// <param name="message">The message in the exception.</param>
  244. /// <param name="innerException">The innerException for this exception.</param>
  245. public ZipException(String message, Exception innerException)
  246. : base(message, innerException)
  247. { }
  248. #if ! (NETCF || SILVERLIGHT)
  249. /// <summary>
  250. /// Come on, you know how exceptions work. Why are you looking at this documentation?
  251. /// </summary>
  252. /// <param name="info">The serialization info for the exception.</param>
  253. /// <param name="context">The streaming context from which to deserialize.</param>
  254. protected ZipException(SerializationInfo info, StreamingContext context)
  255. : base(info, context)
  256. { }
  257. #endif
  258. }
  259. }