Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/dotenvious/errors.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Dotenvious
class FileNotFoundError < ArgumentError
attr_reader :file
def initialize(filename)
@file = filename
super
end
end
end
5 changes: 5 additions & 0 deletions lib/dotenvious/loaders/environment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require_relative "../errors"

module Dotenvious
module Loaders
class Environment
Expand All @@ -19,6 +21,9 @@ def filename
end

def file
if !File.exist?(filename)
raise Dotenvious::FileNotFoundError.new(filename)
end
File.read(filename).split("\n")
end
end
Expand Down
12 changes: 10 additions & 2 deletions lib/dotenvious/loaders/environments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@ module Dotenvious
module Loaders
class Environments
def load_envs
Env.new.load
Example.new.load
begin
Env.new.load
rescue Dotenvious::FileNotFoundError => ex
STDERR.puts "#{ex.file} not found"
end
begin
Example.new.load
rescue Dotenvious::FileNotFoundError => ex
STDERR.puts "#{ex.file} not found"
end
end
end
end
Expand Down