exceptions

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package exceptions provides R7RS exception handling primitives.

Exception Handling (R7RS 6.11)

  • with-exception-handler: install exception handler
  • raise: raise non-continuable exception
  • raise-continuable: raise continuable exception

Error Construction

  • error: create error with message and irritants
  • error-object?: test if value is error object
  • error-object-message: get error message
  • error-object-irritants: get error irritants

Error Predicates

  • read-error?: test for read errors
  • file-error?: test for file errors

Use Extension or AddToRegistry to register all primitives.

Package exceptions provides exception handling primitives.

Index

Constants

This section is empty.

Variables

View Source
var AddToRegistry = Builder.AddToRegistry

AddToRegistry registers all exception primitives.

View Source
var Builder = registry.NewRegistryBuilder(addPrimitives)

Builder aggregates all exception registration functions.

View Source
var Extension = registry.NewExtension("exceptions", AddToRegistry)

Extension is the exceptions extension.

Functions

func PrimError

func PrimError(_ context.Context, mc *machine.MachineContext) error

PrimError implements the error primitive. (error message irritant ...) Creates an error object with the given message and irritants, then raises it.

func PrimErrorObjectIrritants

func PrimErrorObjectIrritants(_ context.Context, mc *machine.MachineContext) error

PrimErrorObjectIrritants implements the error-object-irritants accessor. Returns the list of irritant objects from an error object.

func PrimErrorObjectMessage

func PrimErrorObjectMessage(_ context.Context, mc *machine.MachineContext) error

PrimErrorObjectMessage implements the error-object-message accessor. Returns the message string from an error object.

func PrimErrorObjectQ

func PrimErrorObjectQ(_ context.Context, mc *machine.MachineContext) error

PrimErrorObjectQ implements the error-object? predicate. Returns #t if the argument is an error object created by (error ...), #f otherwise.

func PrimFileErrorQ

func PrimFileErrorQ(_ context.Context, mc *machine.MachineContext) error

PrimFileErrorQ implements the file-error? predicate. R7RS §6.11: Returns #t if obj is an error object raised during file operations.

func PrimRaise

func PrimRaise(_ context.Context, mc *machine.MachineContext) error

PrimRaise implements the raise primitive. (raise obj) Raises a non-continuable exception with obj as the condition.

func PrimRaiseContinuable

func PrimRaiseContinuable(_ context.Context, mc *machine.MachineContext) error

PrimRaiseContinuable implements the raise-continuable primitive. (raise-continuable obj) Raises a continuable exception with obj as the condition. If the handler returns, its return value becomes the value of raise-continuable, and execution continues from the call site per R7RS §6.11.

func PrimReadErrorQ

func PrimReadErrorQ(_ context.Context, mc *machine.MachineContext) error

PrimReadErrorQ implements the read-error? predicate. R7RS §6.11: Returns #t if obj is an error object raised during reading.

func PrimWithExceptionHandler

func PrimWithExceptionHandler(ctx context.Context, mc *machine.MachineContext) error

PrimWithExceptionHandler implements the with-exception-handler primitive. (with-exception-handler handler thunk) Installs handler as exception handler during thunk execution.

Types

This section is empty.

Jump to

Keyboard shortcuts

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