exceptionhandling

package
v0.6.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package exceptionhandling provides Go bindings for the ExceptionHandling framework.

Monitor and debug exceptional conditions in code.

This collection of documents provides the API reference for the Exception Handling framework. This framework provides facilities for monitoring and debugging exceptional conditions in Objective-C code.

Classes

  • NSExceptionHandler: The class provides facilities for monitoring and debugging exceptional conditions in Objective-C programs.

Key Types

Code generated from Apple documentation. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

View Source
var (
	// StackTraceKey is the key for fetching the stack trace (an [NSString] object) in the [userInfo] dictionary of the [NSException] object passed into one of the delegate methods described in [NSExceptionHandlerDelegate].
	//
	// See: https://developer.apple.com/documentation/ExceptionHandling/NSStackTraceKey
	StackTraceKey string
	// UncaughtRuntimeErrorException is identifies an Objective-C runtime error.
	//
	// See: https://developer.apple.com/documentation/ExceptionHandling/NSUncaughtRuntimeErrorException
	UncaughtRuntimeErrorException string
	// UncaughtSystemExceptionException is identifies an uncaught system exception.
	//
	// See: https://developer.apple.com/documentation/ExceptionHandling/NSUncaughtSystemExceptionException
	UncaughtSystemExceptionException string
)

Functions

Types

type INSExceptionHandler

type INSExceptionHandler interface {
	objectivec.IObject

	// Returns a bit mask representing the types of exceptions monitored by the receiver and its handling and logging behavior.
	ExceptionHandlingMask() uint
	// Returns a bit mask representing the types of exceptions that will halt execution for debugging.
	ExceptionHangingMask() uint
	// Sets the bit mask of constants specifying the types of exceptions monitored by the receiver and its handling and logging behavior.
	SetExceptionHandlingMask(aMask uint)
	// Sets the bit mask of constants specifying the types of exceptions that will halt execution for debugging.
	SetExceptionHangingMask(aMask uint)

	// Returns the delegate of the [NSExceptionHandler] object.
	Delegate() objectivec.IObject
	// Sets the delegate of the [NSExceptionHandler] object.
	SetDelegate(anObject objectivec.IObject)
}

An interface definition for the NSExceptionHandler class.

Getting and setting exception masks

Getting and setting the delegate

See: https://developer.apple.com/documentation/ExceptionHandling/NSExceptionHandler

type NS

type NS uint32
const (
	// NSHandleOtherExceptionMask: The exception handler handles exceptions caught by handlers lower than the top-level handler by converting them to NSException objects containing a stack trace.
	NSHandleOtherExceptionMask NS = 512
	// NSHandleTopLevelExceptionMask: The exception handler handles exceptions caught by the top-level handler by converting them to NSException objects containing a stack trace.
	NSHandleTopLevelExceptionMask NS = 128
	// NSHandleUncaughtExceptionMask: The exception handler handles uncaught exceptions by terminating the thread in which they occur.
	NSHandleUncaughtExceptionMask NS = 2
	// NSHandleUncaughtRuntimeErrorMask: The exception handler handles uncaught runtime errors by converting them to NSException objects containing a stack trace.
	NSHandleUncaughtRuntimeErrorMask NS = 32
	// NSHandleUncaughtSystemExceptionMask: The exception handler handles uncaught system exceptions by converting them to NSException objects containing a stack trace.
	NSHandleUncaughtSystemExceptionMask NS = 8
	// NSLogOtherExceptionMask: The exception handler logs exceptions caught by handlers lower than the top-level handler.
	NSLogOtherExceptionMask NS = 256
	// NSLogTopLevelExceptionMask: The exception handler logs exceptions that would be caught by the top-level handler.
	NSLogTopLevelExceptionMask NS = 64
	// NSLogUncaughtExceptionMask: The exception handler logs uncaught exceptions.
	NSLogUncaughtExceptionMask NS = 1
	// NSLogUncaughtRuntimeErrorMask: The exception handler logs uncaught runtime errors.
	NSLogUncaughtRuntimeErrorMask NS = 16
	// NSLogUncaughtSystemExceptionMask: The exception handler logs uncaught system exceptions.
	NSLogUncaughtSystemExceptionMask NS = 4
)

func (NS) String

func (e NS) String() string

type NSExceptionHandler

type NSExceptionHandler struct {
	objectivec.Object
}

The NSExceptionHandler class provides facilities for monitoring and debugging exceptional conditions in Objective-C programs. It works by installing a special uncaught exception handler via the NSSetUncaughtExceptionHandler(_:) function. Consequently, to use the services of NSExceptionHandler, you must not install your own custom uncaught exception handler.

Overview

To use these services, you set a bit mask in the singleton NSExceptionHandler instance and, optionally, a delegate. The constants comprising the bit mask indicate the type of exception to be monitored and the behavior of the NSExceptionHandler object (or, simply, the exception handler). The delegate is asked to approve the logging and handling of each monitored NSException object using the NSExceptionHandlerDelegate protocol.

The constants for configuring exception handler behavior can be categorized in several ways:

- Uncaught exceptions versus caught exceptions—or, more accurately, exceptions that would be caught (for example, by the top-level handler) - Exception type or cause: system exceptions (such as invalid memory accesses), Objective-C runtime errors (such as messages sent to freed objects), and other exceptions - Exception handler behavior: logging the exception (including a stack trace) to the console, handling the exception, and suspending program execution so the debugger can be attached

The way the exception handler handles an exception depends on the type of exception; the exception handler converts system exceptions and runtime errors into NSException objects with a stack trace embedded in their `userInfo` dictionary; for all other uncaught exceptions, it terminates the thread on which they occur . The constants used to configure an NSExceptionHandler object are described in Logging and Handling Constants and System Hang Constants.

The `defaults` command-line system also allows you to set values corresponding to the `enum` constants used to configure the exception handler; see Controlling a Program’s Response to Exceptions for details.

Getting and setting exception masks

Getting and setting the delegate

See: https://developer.apple.com/documentation/ExceptionHandling/NSExceptionHandler

func NSExceptionHandlerFromID

func NSExceptionHandlerFromID(id objc.ID) NSExceptionHandler

NSExceptionHandlerFromID constructs a NSExceptionHandler from an objc.ID.

The NSExceptionHandler class provides facilities for monitoring and debugging exceptional conditions in Objective-C programs. It works by installing a special uncaught exception handler via the NSSetUncaughtExceptionHandler(_:) function. Consequently, to use the services of NSExceptionHandler, you must not install your own custom uncaught exception handler.

func NewNSExceptionHandler

func NewNSExceptionHandler() NSExceptionHandler

NewNSExceptionHandler creates a new NSExceptionHandler instance.

func (NSExceptionHandler) Autorelease

func (e NSExceptionHandler) Autorelease() NSExceptionHandler

Autorelease adds the receiver to the current autorelease pool.

func (NSExceptionHandler) ExceptionHandlingMask

func (e NSExceptionHandler) ExceptionHandlingMask() uint

Returns a bit mask representing the types of exceptions monitored by the receiver and its handling and logging behavior.

Return Value

A bit mask composed of one or more constants specifying the types of exceptions monitored and whether they are handled or logged (or both). See Logging and Handling Constants for information about the constants.

See: https://developer.apple.com/documentation/ExceptionHandling/NSExceptionHandler/exceptionHandlingMask()

func (NSExceptionHandler) ExceptionHangingMask

func (e NSExceptionHandler) ExceptionHangingMask() uint

Returns a bit mask representing the types of exceptions that will halt execution for debugging.

Return Value

A bit mask composed of one or more constants specifying the types of exceptions that will halt execution for debugging. See System Hang Constants for information about the constants.

See: https://developer.apple.com/documentation/ExceptionHandling/NSExceptionHandler/exceptionHangingMask()

func (NSExceptionHandler) Init

Init initializes the instance.

func (NSExceptionHandler) SetDelegate

func (e NSExceptionHandler) SetDelegate(anObject objectivec.IObject)

Sets the delegate of the NSExceptionHandler object.

anObject: The object to receive the delegation messages described in NSExceptionHandlerDelegate

See: https://developer.apple.com/documentation/ExceptionHandling/NSExceptionHandler/setDelegate(_:)

func (NSExceptionHandler) SetExceptionHandlingMask

func (e NSExceptionHandler) SetExceptionHandlingMask(aMask uint)

Sets the bit mask of constants specifying the types of exceptions monitored by the receiver and its handling and logging behavior.

aMask: A bit mask composed of one or more constants specifying the types of exceptions monitored and whether they are handled or logged (or both). You specify multiple constants by performing a bitwise-OR operation. See Logging and Handling Constants for information about the constants.

See: https://developer.apple.com/documentation/ExceptionHandling/NSExceptionHandler/setExceptionHandlingMask(_:)

func (NSExceptionHandler) SetExceptionHangingMask

func (e NSExceptionHandler) SetExceptionHangingMask(aMask uint)

Sets the bit mask of constants specifying the types of exceptions that will halt execution for debugging.

aMask: A bit mask composed of one or more constants specifying the types of exceptions that will halt execution for debugging. You specify multiple constants by performing a bitwise-OR operation. See System Hang Constants for information about the constants.

See: https://developer.apple.com/documentation/ExceptionHandling/NSExceptionHandler/setExceptionHangingMask(_:)

type NSExceptionHandlerClass

type NSExceptionHandlerClass struct {
	// contains filtered or unexported fields
}

func GetNSExceptionHandlerClass

func GetNSExceptionHandlerClass() NSExceptionHandlerClass

GetNSExceptionHandlerClass returns the class object for NSExceptionHandler.

func (NSExceptionHandlerClass) Alloc

Alloc allocates memory for a new instance of the class.

func (NSExceptionHandlerClass) Class

func (nc NSExceptionHandlerClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

func (NSExceptionHandlerClass) DefaultExceptionHandler

func (_NSExceptionHandlerClass NSExceptionHandlerClass) DefaultExceptionHandler() NSExceptionHandler

Returns the singleton NSExceptionHandler instance.

See: https://developer.apple.com/documentation/ExceptionHandling/NSExceptionHandler/default()

type NSHangOn

type NSHangOn uint32
const (
	// NSHangOnOtherExceptionMask: The exception handler suspends execution when it detects an exception that would be handled by an object other than the top-level handler.
	NSHangOnOtherExceptionMask NSHangOn = 16
	// NSHangOnTopLevelExceptionMask: The exception handler suspends execution when it detects an exception that would be handled by the top-level handler.
	NSHangOnTopLevelExceptionMask NSHangOn = 8
	// NSHangOnUncaughtExceptionMask: The exception handler suspends execution when it detects an uncaught exception (other than a system exception or runtime error).
	NSHangOnUncaughtExceptionMask NSHangOn = 1
	// NSHangOnUncaughtRuntimeErrorMask: The exception handler suspends execution when it detects an uncaught runtime error.
	NSHangOnUncaughtRuntimeErrorMask NSHangOn = 4
	// NSHangOnUncaughtSystemExceptionMask: The exception handler suspends execution when it detects an uncaught system exception.
	NSHangOnUncaughtSystemExceptionMask NSHangOn = 2
)

func (NSHangOn) String

func (e NSHangOn) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL