Skip to content
This repository was archived by the owner on Aug 6, 2025. It is now read-only.
This repository was archived by the owner on Aug 6, 2025. It is now read-only.

Impliment user defined error handlers #4

@rdlaitila

Description

@rdlaitila

Upperclass currently halts all execution by calling error() whenever a fatal error is encountered during member lookup or access. For some users this may not be a desirable behavior.

We should permit the user to define a custom error handler within the class:

local MyClass = upperclass:define("MyClass")

function private:__error(ERROR)
    print(ERROR.message, ERROR.code)
end

return upperclass:compile(MyClass)

In addition, we should allow users to define custom error callbacks at the global level:

upperclass = require('upperclass')

function myCustomErrorCallback(ERROR)
    print(ERROR.message, ERROR.code)
end

upperclass:registerErrorHandler(myCustomErrorCallback)

Users should be allowed to register multiple error handlers and upperclass will call each.

It is left up to the user when to halt the program when an upperclass error is encountered.

Default behavior to halt program execution upon an error should remain if no custom handlers are defined.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions