-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy patherror.rb
More file actions
136 lines (126 loc) · 2.92 KB
/
Copy patherror.rb
File metadata and controls
136 lines (126 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# frozen_string_literal: true
module Dry
class Files
# Dry::Files base error
#
# @since 0.1.0
# @api public
class Error < StandardError
end
# Wraps low level I/O errors
#
# @see https://ruby-doc.org/core/Errno.html
#
# @since 0.1.0
# @api public
class IOError < Error
# Instantiate a new `Dry::Files::IOError`
#
# @param cause [Exception] the low level exception
#
# @return [Dry::Files::IOError] the new error
#
# @since 0.1.0
# @api private
def initialize(cause)
super(cause.message)
@_cause = cause
end
# The original exception
#
# @see https://ruby-doc.org/core/Exception.html#method-i-cause
#
# @since 0.1.0
# @api public
def cause
@_cause
end
end
# File manipulations error.
# Raised when the given `target` cannot be found in `path`.
#
# @since 0.1.0
# @api public
class MissingTargetError < Error
# @param target [String,Regexp] the missing target
# @param path [String,Pathname] the file
#
# @return [Dry::Files::MissingTargetError] the new error
#
# @since 0.1.0
# @api private
def initialize(target, path)
super("cannot find `#{target}' in `#{path}'")
@_target = target
@_path = path
end
# The missing target
#
# @return [String, Regexp] the missing target
#
# @since 0.1.0
# @api public
def target
@_target
end
# The missing target
#
# @return [String,Pathname] the file
#
# @since 0.1.0
# @api public
def path
@_path
end
end
# Unknown memory node
#
# Raised by the memory adapter (used for testing purposes)
#
# @since 0.1.0
# @api public
class UnknownMemoryNodeError < Error
# Instantiate a new error
#
# @param node [String] node name
#
# @since 0.1.0
# @api public
def initialize(node)
super("unknown memory node `#{node}'")
end
end
# Not a memory file
#
# Raised by the memory adapter (used for testing purposes)
#
# @since 0.1.0
# @api public
class NotMemoryFileError < Error
# Instantiate a new error
#
# @param path [String] path name
#
# @since 0.1.0
# @api public
def initialize(path)
super("not a memory file `#{path}'")
end
end
# Internal file system adapters can only take
# strings as arguments to their `write` methods.
# (The public API can take string or array of strings)
#
# @since x.x.x
# @api private
class CanOnlyWriteStringError < Error
# Instantiate a new error
#
# @since x.x.x
# @api private
def initialize
super("Can only write a String (use `join` or `to_s`)")
end
end
end
end