PageRenderTime 34ms CodeModel.GetById 19ms app.highlight 9ms RepoModel.GetById 2ms 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
 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
16using System;
17using System.IO;
18using Microsoft.Scripting.Utils;
19
20namespace IronRuby.Builtins {
21    /// <summary>
22    /// Helper class for creating the corresponding .NET exceptions from the Ruby Errno
23    /// </summary>
24    public static class RubyErrno {
25
26        public static string/*!*/ MakeMessage(string message, string/*!*/ baseMessage) {
27            Assert.NotNull(baseMessage);
28            return (message != null) ? String.Concat(baseMessage, " - ", message) : baseMessage;
29        }
30
31        public static string/*!*/ MakeMessage(ref MutableString message, string/*!*/ baseMessage) {
32            Assert.NotNull(baseMessage);
33            string result = MakeMessage(message != null ? message.ConvertToString() : null, baseMessage);
34            message = MutableString.Create(result, message != null ? message.Encoding : RubyEncoding.UTF8);
35            return result;
36        }
37
38        public static ExistError/*!*/ CreateEEXIST() {
39            return new ExistError();
40        }
41
42        public static ExistError/*!*/ CreateEEXIST(string message) {
43            return new ExistError(message);
44        }
45
46        public static ExistError/*!*/ CreateEEXIST(string message, Exception inner) {
47            return new ExistError(message, inner);
48        }
49
50        public static InvalidError/*!*/ CreateEINVAL() {
51            return new InvalidError();
52        }
53
54        public static InvalidError/*!*/ CreateEINVAL(string message) {
55            return new InvalidError(message);
56        }
57
58        public static InvalidError/*!*/ CreateEINVAL(string message, Exception inner) {
59            return new InvalidError(message, inner);
60        }
61
62        public static FileNotFoundException/*!*/ CreateENOENT() {
63            return new FileNotFoundException();
64        }
65
66        public static FileNotFoundException/*!*/ CreateENOENT(string message, Exception inner) {
67            return new FileNotFoundException(message, inner);
68        }
69
70        public static FileNotFoundException/*!*/ CreateENOENT(string message) {
71            return new FileNotFoundException(message);
72        }
73    }
74}