Skip to content

Unhelpful Error when Attempting to Add Non-Existent Static Directory #36

@portrik

Description

@portrik

Description

I have run into this issue accidentally when trying to bundle a non-existent static directory. Instead of getting some sensible error in the vein of StaticDirNotFound or something similar, I instead got CannotCreateTempDirectory(Enoent).

The error originates at the start of do_build, maybe just mapping the errors from simplifile more granularly could solve the issue? If possible, I could take a swing at a PR.

Reproduction Steps

The code below will echo the CannotCreateTempDirectory(Enoent) error.

import gleam/io
import lustre/element/html.{html}
import lustre/ssg

const build_directory = "./dist"

pub fn main() {
  let build_result =
    ssg.new(build_directory)
    // Adding the non-existent static dir produces `CannotCreateTempDirectory(Enoent)` in the echo below
    |> ssg.add_static_dir("./does-not-exist")
    |> ssg.add_static_route(
      "/",
      html([], [html.h1([], [html.text("This will never render")])]),
    )
    |> ssg.build

  case build_result {
    Ok(_) -> io.println("Success")

    Error(error) -> {
      echo error

	  Nil
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions