PageRenderTime 56ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/Merlin/Main/Languages/Ruby/Ruby/Builtins/Exceptions.cs

https://github.com/mattsnyder/ironruby
C# | 282 lines | 214 code | 51 blank | 17 comment | 0 complexity | 80fe858649b757a151776dc9fb84cf26 MD5 | raw file
  1. /* ****************************************************************************
  2. *
  3. * Copyright (c) Microsoft Corporation.
  4. *
  5. * This source code is subject to terms and conditions of the Microsoft Public License. A
  6. * copy of the license can be found in the License.html file at the root of this distribution. If
  7. * you cannot locate the Microsoft Public License, please send an email to
  8. * ironruby@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
  9. * by the terms of the Microsoft Public License.
  10. *
  11. * You must not remove this notice, or any other, from this software.
  12. *
  13. *
  14. * ***************************************************************************/
  15. using System;
  16. using Microsoft.Scripting.Utils;
  17. using IronRuby.Runtime;
  18. using System.Runtime.InteropServices;
  19. namespace IronRuby.Builtins {
  20. [Serializable]
  21. public class LocalJumpError : SystemException {
  22. [NonSerialized]
  23. private readonly RuntimeFlowControl _skipFrame;
  24. /// <summary>
  25. /// The exception cannot be rescued in this frame if set.
  26. /// </summary>
  27. internal RuntimeFlowControl SkipFrame {
  28. get { return _skipFrame; }
  29. }
  30. internal LocalJumpError(string/*!*/ message, RuntimeFlowControl/*!*/ skipFrame)
  31. : this(message, (Exception)null) {
  32. Assert.NotNull(message, skipFrame);
  33. _skipFrame = skipFrame;
  34. }
  35. public LocalJumpError() : this(null, (Exception)null) { }
  36. public LocalJumpError(string message) : this(message, (Exception)null) { }
  37. public LocalJumpError(string message, Exception inner) : base(message, inner) { }
  38. #if !SILVERLIGHT
  39. protected LocalJumpError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
  40. : base(info, context) { }
  41. #endif
  42. }
  43. [Serializable]
  44. public class SystemExit : Exception {
  45. private readonly int _status;
  46. public int Status {
  47. get { return _status; }
  48. }
  49. public SystemExit(int status, string message)
  50. : this(message) {
  51. _status = status;
  52. }
  53. public SystemExit(int status)
  54. : this() {
  55. _status = status;
  56. }
  57. public SystemExit() : this(null, null) { }
  58. public SystemExit(string message) : this(message, null) { }
  59. public SystemExit(string message, Exception inner) : base(message, inner) { }
  60. #if !SILVERLIGHT
  61. protected SystemExit(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
  62. : base(info, context) { }
  63. #endif
  64. }
  65. [Serializable]
  66. public class ScriptError : Exception {
  67. public ScriptError() : this(null, null) { }
  68. public ScriptError(string message) : this(message, null) { }
  69. public ScriptError(string message, Exception inner) : base(message, inner) { }
  70. #if !SILVERLIGHT
  71. protected ScriptError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
  72. : base(info, context) { }
  73. #endif
  74. }
  75. [Serializable]
  76. public class NotImplementedError : ScriptError {
  77. public NotImplementedError() : this(null, null) { }
  78. public NotImplementedError(string message) : this(message, null) { }
  79. public NotImplementedError(string message, Exception inner) : base(message, inner) { }
  80. #if !SILVERLIGHT
  81. protected NotImplementedError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
  82. : base(info, context) { }
  83. #endif
  84. }
  85. [Serializable]
  86. public class LoadError : ScriptError {
  87. public LoadError() : this(null, null) { }
  88. public LoadError(string message) : this(message, null) { }
  89. public LoadError(string message, Exception inner) : base(message, inner) { }
  90. #if !SILVERLIGHT
  91. protected LoadError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
  92. : base(info, context) { }
  93. #endif
  94. }
  95. [Serializable]
  96. public class SystemStackError : SystemException {
  97. public SystemStackError() : this(null, null) { }
  98. public SystemStackError(string message) : this(message, null) { }
  99. public SystemStackError(string message, Exception inner) : base(message, inner) { }
  100. #if !SILVERLIGHT
  101. protected SystemStackError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
  102. : base(info, context) { }
  103. #endif
  104. }
  105. [Serializable]
  106. public class RegexpError : SystemException {
  107. public RegexpError() : this(null, null) { }
  108. public RegexpError(string message) : this(message, null) { }
  109. public RegexpError(string message, Exception inner) : base(message, inner) { }
  110. #if !SILVERLIGHT
  111. protected RegexpError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
  112. : base(info, context) { }
  113. #endif
  114. }
  115. [Serializable]
  116. public class EncodingError : SystemException {
  117. public EncodingError() : this(null, null) { }
  118. public EncodingError(string message) : this(message, null) { }
  119. public EncodingError(string message, Exception inner) : base(message, inner) { }
  120. #if !SILVERLIGHT
  121. protected EncodingError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
  122. : base(info, context) { }
  123. #endif
  124. }
  125. [Serializable]
  126. public class EncodingCompatibilityError : EncodingError {
  127. public EncodingCompatibilityError() : this(null, null) { }
  128. public EncodingCompatibilityError(string message) : this(message, null) { }
  129. public EncodingCompatibilityError(string message, Exception inner) : base(message, inner) { }
  130. #if !SILVERLIGHT
  131. protected EncodingCompatibilityError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
  132. : base(info, context) { }
  133. #endif
  134. }
  135. [Serializable]
  136. public class RuntimeError : SystemException {
  137. public RuntimeError() : this(null, null) { }
  138. public RuntimeError(string message) : this(message, null) { }
  139. public RuntimeError(string message, Exception inner) : base(message, inner) { }
  140. #if !SILVERLIGHT
  141. protected RuntimeError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
  142. : base(info, context) { }
  143. #endif
  144. }
  145. [Serializable]
  146. public class SyntaxError : ScriptError {
  147. private readonly string _file;
  148. private readonly string _lineSourceCode;
  149. private readonly int _line;
  150. private readonly int _column;
  151. private readonly bool _hasLineInfo;
  152. public SyntaxError() : this(null, null) { }
  153. public SyntaxError(string message) : this(message, null) { }
  154. public SyntaxError(string message, Exception inner) : base(message, inner) { }
  155. internal string File {
  156. get { return _file; }
  157. }
  158. internal int Line {
  159. get { return _line; }
  160. }
  161. internal int Column {
  162. get { return _column; }
  163. }
  164. internal string LineSourceCode {
  165. get { return _lineSourceCode; }
  166. }
  167. internal bool HasLineInfo {
  168. get { return _hasLineInfo; }
  169. }
  170. internal SyntaxError(string/*!*/ message, string file, int line, int column, string lineSourceCode)
  171. : base(message) {
  172. _file = file;
  173. _line = line;
  174. _column = column;
  175. _lineSourceCode = lineSourceCode;
  176. _hasLineInfo = true;
  177. }
  178. #if !SILVERLIGHT
  179. protected SyntaxError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
  180. : base(info, context) { }
  181. #endif
  182. }
  183. [Serializable]
  184. public class ExistError : ExternalException {
  185. private const string/*!*/ M = "File exists";
  186. public ExistError() : this(null, null) { }
  187. public ExistError(string message) : this(message, null) { }
  188. public ExistError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { }
  189. public ExistError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); }
  190. #if !SILVERLIGHT
  191. protected ExistError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
  192. : base(info, context) { }
  193. #endif
  194. }
  195. [Serializable]
  196. public class BadFileDescriptorError : ExternalException {
  197. private const string/*!*/ M = "Bad file descriptor";
  198. public BadFileDescriptorError() : this(null, null) { }
  199. public BadFileDescriptorError(string message) : this(message, null) { }
  200. public BadFileDescriptorError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { }
  201. public BadFileDescriptorError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); }
  202. #if !SILVERLIGHT
  203. protected BadFileDescriptorError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
  204. : base(info, context) { }
  205. #endif
  206. }
  207. [Serializable]
  208. public class ExecFormatError : ExternalException {
  209. private const string/*!*/ M = "Exec format error";
  210. public ExecFormatError() : this(null, null) { }
  211. public ExecFormatError(string message) : this(message, null) { }
  212. public ExecFormatError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { }
  213. public ExecFormatError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); }
  214. #if !SILVERLIGHT
  215. protected ExecFormatError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
  216. : base(info, context) { }
  217. #endif
  218. }
  219. [Serializable]
  220. public class InvalidError : ExternalException {
  221. private const string/*!*/ M = "Invalid argument";
  222. public InvalidError() : this(null, null) { }
  223. public InvalidError(string message) : this(message, null) { }
  224. public InvalidError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { }
  225. public InvalidError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); }
  226. #if !SILVERLIGHT
  227. protected InvalidError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
  228. : base(info, context) { }
  229. #endif
  230. }
  231. }