---
title: "traceback"
description: "Builds a Byte-formatted traceback of the current thread."
---

```lua
traceback(message: string?): string
```

---

## Aliases

- `debug.traceback`

---

## Arguments

<ParamField body="message" type="string">
  The message or diagnostic prefix.
</ParamField>

---

## Returns

<ResponseField name="traceback" type="string">
  The Byte-formatted stack trace, including the optional prefix.
</ResponseField>

Also accepts traceback(thread, message). The global function uses Stack Begin/Stack End and honors setstackhidden; it has no start-level parameter. The registered debug.traceback field is subsequently replaced when the host debug table is copied, so use global traceback for this Byte contract. The host table version can have different arguments and formatting.

**Related types:** [Debug types & behavior](/reference/debug/types).

---

## Example

```lua
print(traceback("Docs diagnostic"))
```
