docs » hs.crash

Various features/facilities for developers who are working on Hammerspoon itself, or writing extensions for it. It is extremely unlikely that you should need any part of this extension, in a normal user configuration.

API Overview

API Documentation

Functions

attemptMemoryRelease
Signature hs.crash.attemptMemoryRelease()
Type Function
Description Attempts to reduce RAM usage of Hammerspoon
Parameters
  • None
Returns
  • None
Notes
  • This function will print some memory usage numbers (in bytes) to the Hammerspoon Console before and after forcing Lua's garbage collector
Source extensions/crash/crash.lua line 40
crash
Signature hs.crash.crash()
Type Function
Description Causes Hammerspoon to immediately crash
Parameters
  • None
Returns
  • None
Notes
  • This is for testing purposes only, you are extremely unlikely to need this in normal Hammerspoon usage
Source extensions/crash/libcrash.m line 12
crashKV
Signature hs.crash.crashKV(key, value)
Type Function
Description Sets a key/value pair in any Sentry crash dump generated by this Hamerspoon session
Parameters
  • key - A string containing the key name of the pair
  • value - A string containing the value of the pair
Returns
  • None
Source extensions/crash/libcrash.m line 72
crashLog
Signature hs.crash.crashLog(logMessage)
Type Function
Description Leaves a breadcrumb log message in any Sentry crash dump generated by this Hammerspoon session
Parameters
  • logMessage - A string containing a message to log
Returns
  • None
Notes
  • This is probably only useful to extension developers. If you are trying to track down a confusing crash, and you have access to the Sentry project for Hammerspoon (or access to someone who has access!), this can be a useful way to leave breadcrumbs from Lua in the crash dump
Source extensions/crash/libcrash.m line 53
dumpCLIBS
Signature hs.crash.dumpCLIBS() -> table
Type Function
Description Dumps the contents of Lua's CLIBS registry
Parameters
  • None
Returns
  • A table containing all the paths of C libraries that have been loaded into the Lua runtime
Notes
  • This is probably only useful to extension developers as a useful way of ensuring that you are loading C libraries from the places you expect.
Source extensions/crash/crash.lua line 7
residentSize
Signature hs.crash.residentSize() -> integer or nil
Type Function
Description Gets the resident size of the Hammerspoon process
Parameters
  • None
Returns
  • An integer containing the amount of RAM in use by Hammerspoon (in bytes), or nil if an error occurred
Source extensions/crash/libcrash.m line 107
throwObjCException
Signature hs.crash.throwObjCException(name, message)
Type Function
Description Causes Hammerspoon to generate an Objective C exception
Parameters
  • name - A string containing the name of the exception
  • message - A human readabke string explaining the exception
Returns
  • None
Notes
  • Outside of a context of a Lua pcall() (or a C lua_pcall()), this will cause Hammerspoon to exit. We follow the safe behaviour of terminating the app on any unhandled Objective C exception.
Source extensions/crash/libcrash.m line 31