Erlang basics · Lesson 31 (open contents)
Prove the project is done
If a missing file already produces an error message, must its exit status also be checked?
Before running: In a scratch directory's erl run {ok, nb_acceptance} = c(nb_acceptance), ok = escript:create("nb_acceptance.escript", [shebang, {beam, "nb_acceptance.beam"}]). Continue only after both succeed. Then run ok = file:write_file("report.txt", <<"hello beam\nagain\n">>), ok = file:write_file("empty.txt", <<>>), ok = file:write_file("invalid.txt", <<255>>). Keep missing.txt absent. Open another system terminal in the same directory; run escript nb_acceptance.escript report.txt, then echo $?. Repeat with empty.txt, invalid.txt, and missing.txt. Do not call the halting main/1 directly in your current erl. Recompile and repackage after edits.
PredictWhen missing.txt is absent, what error text and exit status are produced?
These are fixed example results. This page does not execute code on your computer. Full project examples and reference material are on the deeper page.
Used here: Lesson 26 · Write the project promiseLesson 27 · Parse one real lineLesson 29 · Make the promise executableLesson 30 · Package the edge and leave clues
Go deeper: full examples, original exercises and further reading →