Class: Looped::Tools::ReadFile

Inherits:
DSPy::Tools::Base
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/looped/tools/read_file.rb

Instance Method Summary collapse

Instance Method Details

#call(path:) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/looped/tools/read_file.rb', line 13

def call(path:)
  resolved_path = resolve_path(path)
  File.read(resolved_path)
rescue Errno::ENOENT
  "Error: File not found: #{path}"
rescue Errno::EACCES
  "Error: Permission denied: #{path}"
rescue StandardError => e
  "Error: #{e.message}"
end