How to catch error from @embedFile?

embedding a non-existent file will fail;

_ = @embedFile("doesnotexist")

is there a way to try and catch this?

try/catch are runtime things. This is a compile error.

2 Likes

uh right, seems I need to rethink my approach :wink:

A better approach might be to handle finding the file at build time, where you can use more of the runtime stdlib io (and thus try/catch). Then you would add the found files as anonymous imports/modules that can still be embedded using @embedFile("anon_mod_name").

The build guide shows some of this here which I think can be adapted to your needs.

2 Likes

discovered yesterday that @dude_the_builder made a related tutorial video (code gen) - very helpful :slight_smile:

2 Likes