# Anoma NockVM error reporting

**URL:** <https://forum.anoma.net/t/anoma-nockvm-error-reporting/1142>\
**Category:** Protocol Design\
**Created:** [February 3, 2025, 2:02pm UTC](https://forum.anoma.net/t/anoma-nockvm-error-reporting/1142 "2025-02-03T14:02:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulcadman](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@paulcadman](https://forum.anoma.net/u/paulcadman)\
**Post date:** [February 3, 2025, 2:02pm UTC](https://forum.anoma.net/t/anoma-nockvm-error-reporting/1142/1 "2025-02-03T14:02:22Z")

</div>

## Anoma NockVM error reporting

The Anoma NockVM is used to interpret Nock code that’s submitted to Anoma. For  
example:

1. Nock computations via the `/prove` endpoint (used to compute transaction  
candidates)
2. Transaction candidates submitted to the mempool
3. Logic functions in Resources

An Anoma NockVM errors can occur when:

1. The submitted Nock code is invalid (e.g it cannot be decoded)
2. The interpreter reaches an error condition in Nock code
3. A crash happens in a jet (i.e Elixir code)

The user only recieves feedback if a NockVM error occurs when calling `/prove`.  
There’s currently no way to see errors that happen during logic function or  
transaction candidate execution.

These errors are reported using the single error value `:error` with no  
additional context.

This makes it hard for application authors to debug because it’s hard to  
determine the cause of an error.

### Ideas for error reporting

1. Each `:error` value could have a string payload describing why the error  
occured. For example this could contain the name of the jet that failed if  
the error occured in a jet.

2. Provide a mechanism for logging VM errors that occur in transaction  
candidates or logic functions that can be queried by the application author.  
Also making trace logs emitted by transaction candidates / logic functions  
would be useful here.

More long term ideas that we’ve discussed before:

1. Provide an interface for injecting Juvix call-stack and source file/line  
number information into Nock terms so we can report a stack trace of the  
error to the user.

---

<div class="post-metadata">

**Author:** ![ray](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@ray](https://forum.anoma.net/u/ray)\
**Post date:** [February 3, 2025, 4:44pm UTC](https://forum.anoma.net/t/anoma-nockvm-error-reporting/1142/2 "2025-02-03T16:44:20Z")

</div>

We will be able to dump stack traces from the stateful VM (on error result, or interrupt) — the compiler will also be able to put Juvix stack trace information in by wrapping forms in hints (the hint’s semantic: push the hint value, evaluate the hinted subformula, pop the stack) when it’s emitting debug symbols. This is one of the things we need the stateful VM to do right (without further spaghettifying the already shaky interpreter).
