---
title: Internal
description: The handler failed with an error it did not declare, so the caller gets no code of its own.
related:
  - /lunas/return-errors
  - /observe/read-logs
  - /errors
---

`Internal` means the handler failed in a way it did not declare. The status is 500.

## Issue

A call fails with `Internal`. In a luna, `ctx.call` throws a `LunaCallError` whose `kind` is `"Internal"` and whose `retryable` is false.

## Cause

A handler's caller gets a code only for errors the handler declares in `errors` and throws with `ctx.fail`. Everything else becomes `Internal`:

- An exception the handler did not catch, such as a `TypeError`.
- `ctx.fail` with a code missing from the handler's `errors`.
- A declared error from a luna it called, left uncaught, when this handler does not declare the same code.
- A query handler that tries to write.

The handler's writes are undone, as for any failed call.

`Internal` differs from a declared error, which answers with status 422 and your own code. It also differs from [`OutcomeUnknown`](/errors/outcome-unknown), where the luna stopped and nobody knows whether the call ran.

## Solution

Do not retry. The same call fails the same way.

1. Find the failed calls with [`luna logs`](/cli/logs) `--outcome error`, and read the error's message.
2. Fix the bug, or declare the error so the caller can act on it.

```ts luna/lunas/wallet.ts
charge: h({ args: { amount: t.int() }, errors: { Insufficient: t.object({ left: t.int() }) } }, (ctx, { amount }) => {
  if (amount > 100) ctx.fail("Insufficient", { left: 100 });
  return 100 - amount;
}),
```

[Return errors](/lunas/return-errors) shows how to declare errors and pass them on.
