PageRenderTime 64ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/IronPython_Main/Languages/Ruby/Ruby/Builtins/RubyErrno.cs

#
C# | 74 lines | 44 code | 13 blank | 17 comment | 3 complexity | 32c6d682ae758f445c45e2bb2a2085e0 MD5 | raw file
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception, CPL-1.0, CC-BY-SA-3.0, BSD-3-Clause, ISC, AGPL-3.0, LGPL-2.1, Apache-2.0
  1. /* ****************************************************************************
  2. *
  3. * Copyright (c) Microsoft Corporation.
  4. *
  5. * This source code is subject to terms and conditions of the Apache License, Version 2.0. 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 Apache License, Version 2.0, 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 Apache License, Version 2.0.
  10. *
  11. * You must not remove this notice, or any other, from this software.
  12. *
  13. *
  14. * ***************************************************************************/
  15. using System;
  16. using System.IO;
  17. using Microsoft.Scripting.Utils;
  18. namespace IronRuby.Builtins {
  19. /// <summary>
  20. /// Helper class for creating the corresponding .NET exceptions from the Ruby Errno
  21. /// </summary>
  22. public static class RubyErrno {
  23. public static string/*!*/ MakeMessage(string message, string/*!*/ baseMessage) {
  24. Assert.NotNull(baseMessage);
  25. return (message != null) ? String.Concat(baseMessage, " - ", message) : baseMessage;
  26. }
  27. public static string/*!*/ MakeMessage(ref MutableString message, string/*!*/ baseMessage) {
  28. Assert.NotNull(baseMessage);
  29. string result = MakeMessage(message != null ? message.ConvertToString() : null, baseMessage);
  30. message = MutableString.Create(result, message != null ? message.Encoding : RubyEncoding.UTF8);
  31. return result;
  32. }
  33. public static ExistError/*!*/ CreateEEXIST() {
  34. return new ExistError();
  35. }
  36. public static ExistError/*!*/ CreateEEXIST(string message) {
  37. return new ExistError(message);
  38. }
  39. public static ExistError/*!*/ CreateEEXIST(string message, Exception inner) {
  40. return new ExistError(message, inner);
  41. }
  42. public static InvalidError/*!*/ CreateEINVAL() {
  43. return new InvalidError();
  44. }
  45. public static InvalidError/*!*/ CreateEINVAL(string message) {
  46. return new InvalidError(message);
  47. }
  48. public static InvalidError/*!*/ CreateEINVAL(string message, Exception inner) {
  49. return new InvalidError(message, inner);
  50. }
  51. public static FileNotFoundException/*!*/ CreateENOENT() {
  52. return new FileNotFoundException();
  53. }
  54. public static FileNotFoundException/*!*/ CreateENOENT(string message, Exception inner) {
  55. return new FileNotFoundException(message, inner);
  56. }
  57. public static FileNotFoundException/*!*/ CreateENOENT(string message) {
  58. return new FileNotFoundException(message);
  59. }
  60. }
  61. }