Skip to content

Commit

Permalink
Set error message in erlang ffi
Browse files Browse the repository at this point in the history
and added a test for it that works for both js and erlang
  • Loading branch information
stickyPiston committed Apr 13, 2024
1 parent b0f56fc commit a8cb0ec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/dot_env_ffi.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
get_env(Name) ->
case os:getenv(binary_to_list(Name)) of
false ->
{error, nil};
{error, list_to_binary(io_lib:format("key ~s is not set", [Name]))};
Value ->
{ok, list_to_binary(Value)}
end.
Expand Down
3 changes: 3 additions & 0 deletions test/dot_env_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ pub fn load_normal_test() {

env.get("SPACED_KEY")
|> should.equal(Ok("parsed"))

env.get("DOESNT_EXIST")
|> should.equal(Error("key DOESNT_EXIST is not set"))
}

pub fn load_multiline_test() {
Expand Down

0 comments on commit a8cb0ec

Please sign in to comment.