(ArgumentError) argument error :erlang.byte_size(:enoent)

def create_error_mail(email_address, content) do
    base_email()
    |> to(email_address)
    |> subject("Error - Shortner Bulk Upload Data")
    |> html_body(generate_mail_content(content))
  end

  def generate_mail_content(content) do
   Line 27:    "<h2>Unable to process request</h2>" <>
    "Message : " <> content <>
    "<h4>Please check the filepath and try again</h4>"
  end

Getting this below error on server but working fine locally.

    :erlang.byte_size(:enoent)
    (shortner) lib/shortner/email.ex:27: Shortner.Email.generate_mail_content/1

Library Used
:bamboo,
:bamboo_smtp

content is probably :enoent, which again is a “POSIX” error, which tells you that some “entity did not exist”.

You probably read the content from a file that did not exist.

1 Like

This is the code that is giving the content aka errors.

    with {:ok, :done} <- download_csv(csv_path) do
      read_csv("files/" <> csv_path) 
        |> dump_to_csv
        |> add_attachment
        |> Email.create(email)
        |> Email.send_email
      File.rm("files/" <> csv_path)
    else
      {:error, errors} -> Email.create_error_mail(email, errors) |> Email.send_email
    end
  end

How can I fix that, please let me know?

download_csv is downloading csv from the S3 bucket.

My assumption is, that download_csv/1 returns {:error, :enoent}, as only from there it can fall into the with/1s :else branch.

1 Like

Yes, you are correct.

Thanks.