Skip to Content
defold-typescript
Get startedGuidesAPILibraries
Defold

crash

Native crash logging functions and constants.

Functions

crash.get_backtrace(handle: number): string[]

A table is returned containing the addresses of the call stack.

Parameters

  • handle: number — crash dump handle

Returns

  • backtrace: string[] — table containing the backtrace

crash.get_extra_data(handle: number): string

The format of read text blob is platform specific and not guaranteed but can be useful for manual inspection.

Parameters

  • handle: number — crash dump handle

Returns

  • blob: string — string with the platform specific data

crash.get_modules(handle: number): crash.ModuleInfo[]

get all loaded modules from when the crash occured

Parameters

  • handle: number — crash dump handle

Returns

crash.get_signum(handle: number): number

read signal number from a crash report

Parameters

  • handle: number — crash dump handle

Returns

  • signal: number — signal number

crash.get_sys_field(handle: number, index: crash.SysField): string | undefined

reads a system field from a loaded crash dump

Parameters

Returns

  • value: string | undefined — value recorded in the crash dump, or nil if it didn't exist

crash.get_user_field(handle: number, index: crash.UserField): string

reads user field from a loaded crash dump

Parameters

  • handle: number — crash dump handle
  • index: crash.UserField — user data slot index. 0️⃣ 0-based; passed to Defold unchanged.

Returns

  • value: string — user data value recorded in the crash dump

crash.load_previous(): number | undefined

The crash dump will be removed from disk upon a successful load, so loading is one-shot.

Returns

  • handle: number | undefined — handle to the loaded dump, or nil if no dump was found

crash.release(handle: number): void

releases a previously loaded crash dump

Parameters

  • handle: number — handle to loaded crash dump

crash.set_file_path(path: string): void

Crashes occuring before the path is set will be stored to a default engine location.

Parameters

  • path: string — file path to use

crash.set_user_field(index: crash.UserField, value: string): void

Store a user value that will get written to a crash dump when a crash occurs. This can be user id:s, breadcrumb data etc. There are 32 slots indexed from 0. Each slot stores at most 255 characters.

Parameters

  • index: crash.UserField — slot index. 0-indexed. 0️⃣ 0-based; passed to Defold unchanged.
  • value: string — string value to store

crash.write_dump(): void

Performs the same steps as if a crash had just occured but allows the program to continue. The generated dump can be read by crash.load_previous

Constants

crash.SYSFIELD_ANDROID_BUILD_FINGERPRINT: number & { readonly __brand: "crash.SYSFIELD_ANDROID_BUILD_FINGERPRINT" }

android build fingerprint

crash.SYSFIELD_DEVICE_LANGUAGE: number & { readonly __brand: "crash.SYSFIELD_DEVICE_LANGUAGE" }

system device language as reported by sys.get_sys_info

crash.SYSFIELD_DEVICE_MODEL: number & { readonly __brand: "crash.SYSFIELD_DEVICE_MODEL" }

device model as reported by sys.get_sys_info

crash.SYSFIELD_ENGINE_HASH: number & { readonly __brand: "crash.SYSFIELD_ENGINE_HASH" }

engine version as hash

crash.SYSFIELD_ENGINE_VERSION: number & { readonly __brand: "crash.SYSFIELD_ENGINE_VERSION" }

engine version as release number

crash.SYSFIELD_LANGUAGE: number & { readonly __brand: "crash.SYSFIELD_LANGUAGE" }

system language as reported by sys.get_sys_info

crash.SYSFIELD_MANUFACTURER: number & { readonly __brand: "crash.SYSFIELD_MANUFACTURER" }

device manufacturer as reported by sys.get_sys_info

crash.SYSFIELD_MAX: number & { readonly __brand: "crash.SYSFIELD_MAX" }

The max number of sysfields.

crash.SYSFIELD_SYSTEM_NAME: number & { readonly __brand: "crash.SYSFIELD_SYSTEM_NAME" }

system name as reported by sys.get_sys_info

crash.SYSFIELD_SYSTEM_VERSION: number & { readonly __brand: "crash.SYSFIELD_SYSTEM_VERSION" }

system version as reported by sys.get_sys_info

crash.SYSFIELD_TERRITORY: number & { readonly __brand: "crash.SYSFIELD_TERRITORY" }

system territory as reported by sys.get_sys_info

crash.USERFIELD_MAX: number & { readonly __brand: "crash.USERFIELD_MAX" }

The max number of user fields.

crash.USERFIELD_SIZE: number & { readonly __brand: "crash.USERFIELD_SIZE" }

The max size of a single user field.

Types

interface crash.ModuleInfo { name: string; address: string; }

type crash.SysField = typeof crash.SYSFIELD_ENGINE_VERSION | typeof crash.SYSFIELD_ENGINE_HASH | typeof crash.SYSFIELD_DEVICE_MODEL | typeof crash.SYSFIELD_MANUFACTURER | typeof crash.SYSFIELD_SYSTEM_NAME | typeof crash.SYSFIELD_SYSTEM_VERSION | typeof crash.SYSFIELD_LANGUAGE | typeof crash.SYSFIELD_DEVICE_LANGUAGE | typeof crash.SYSFIELD_TERRITORY | typeof crash.SYSFIELD_ANDROID_BUILD_FINGERPRINT

type crash.UserField = number

On this page

Functionscrash.get_backtrace(handle: number): string[]crash.get_extra_data(handle: number): stringcrash.get_modules(handle: number): crash.ModuleInfo[]crash.get_signum(handle: number): numbercrash.get_sys_field(handle: number, index: crash.SysField): string | undefinedcrash.get_user_field(handle: number, index: crash.UserField): stringcrash.load_previous(): number | undefinedcrash.release(handle: number): voidcrash.set_file_path(path: string): voidcrash.set_user_field(index: crash.UserField, value: string): voidcrash.write_dump(): voidConstantscrash.SYSFIELD_ANDROID_BUILD_FINGERPRINT: number & { readonly __brand: "crash.SYSFIELD_ANDROID_BUILD_FINGERPRINT" }crash.SYSFIELD_DEVICE_LANGUAGE: number & { readonly __brand: "crash.SYSFIELD_DEVICE_LANGUAGE" }crash.SYSFIELD_DEVICE_MODEL: number & { readonly __brand: "crash.SYSFIELD_DEVICE_MODEL" }crash.SYSFIELD_ENGINE_HASH: number & { readonly __brand: "crash.SYSFIELD_ENGINE_HASH" }crash.SYSFIELD_ENGINE_VERSION: number & { readonly __brand: "crash.SYSFIELD_ENGINE_VERSION" }crash.SYSFIELD_LANGUAGE: number & { readonly __brand: "crash.SYSFIELD_LANGUAGE" }crash.SYSFIELD_MANUFACTURER: number & { readonly __brand: "crash.SYSFIELD_MANUFACTURER" }crash.SYSFIELD_MAX: number & { readonly __brand: "crash.SYSFIELD_MAX" }crash.SYSFIELD_SYSTEM_NAME: number & { readonly __brand: "crash.SYSFIELD_SYSTEM_NAME" }crash.SYSFIELD_SYSTEM_VERSION: number & { readonly __brand: "crash.SYSFIELD_SYSTEM_VERSION" }crash.SYSFIELD_TERRITORY: number & { readonly __brand: "crash.SYSFIELD_TERRITORY" }crash.USERFIELD_MAX: number & { readonly __brand: "crash.USERFIELD_MAX" }crash.USERFIELD_SIZE: number & { readonly __brand: "crash.USERFIELD_SIZE" }Typesinterface crash.ModuleInfo { name: string; address: string; }type crash.SysField = typeof crash.SYSFIELD_ENGINE_VERSION | typeof crash.SYSFIELD_ENGINE_HASH | typeof crash.SYSFIELD_DEVICE_MODEL | typeof crash.SYSFIELD_MANUFACTURER | typeof crash.SYSFIELD_SYSTEM_NAME | typeof crash.SYSFIELD_SYSTEM_VERSION | typeof crash.SYSFIELD_LANGUAGE | typeof crash.SYSFIELD_DEVICE_LANGUAGE | typeof crash.SYSFIELD_TERRITORY | typeof crash.SYSFIELD_ANDROID_BUILD_FINGERPRINTtype crash.UserField = number