Skip to content

Better error handling #15

Description

@pablomayobre

Currently ScreenManager doesn't check:

  • If the screens are tables when calling ScreenManager.init. So it will error when trying to index screen.new()
  • If the returned value from screen.new() is a table. So new() could return a string (for example) and later on when trying to index it in search for the callbacks you would get an error trying to index a string
  • If the callback is defined. So it will error when trying to index a callback which wasn't defined in the screen
  • If the callback is actually a function. So if for example screen.directorydropped was a string ScreenManager.directorydropped would try to call a string resulting in an error

I know that most of this issues can be fixed by using the suggested Screen.lua as a base class, but it would be great if ScreenManager errored when it found one of this akward cases (which are of course not the libraries fault but the users fault)

I consider that the following would be the best way to handle each case:

  • In the case of new() not returning a table it should probably error
  • In ScreenManager.init if the nscreens wasn't a table containing tables that have a .new() function then it should error
  • If the callback is not defined it should be ignored
  • If the callback is defined but not a function then it should be ignored

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions