Home / Docs / Diagnostics

U6001: main failed

Release v0.4.0

When main fails, una run stops and reports the variant of the failure as U6001 at the name of main, with exit code 1 (spec/04 §8). The payload fields of the failure are shown only when their labels are public, so the report never reveals labeled data; lines the program printed before the failure stay printed. Handle the failure inside main, with an if error clause or attempt, or make sure the path that fails is never taken.

The repair at a glance

diff
  module demo

  pub kind StartError = | MissingConfig

  check_config(ready: Bool) -> Unit
    fails StartError
  =
    if ready then unit else fail MissingConfig

  pub main() -> Unit
    fails StartError
  =
-   check_config(false)
+   check_config(true)
      if error pass

Failing example

una
module demo

pub kind StartError = | MissingConfig

check_config(ready: Bool) -> Unit
  fails StartError
=
  if ready then unit else fail MissingConfig

pub main() -> Unit
  fails StartError
=
  check_config(false)
    if error pass

Fixed example

una
module demo

pub kind StartError = | MissingConfig

check_config(ready: Bool) -> Unit
  fails StartError
=
  if ready then unit else fail MissingConfig

pub main() -> Unit
  fails StartError
=
  check_config(true)
    if error pass