Comments (11)
OOI do you have an idea of how this would work? I was wondering about putting all of the setup.lua work in a function and then xpcall()'ing it, like we do at the end of the file for init.lua?
from hammerspoon.
MJLua.m now pcall
s setup.lua, surely we can have error handling there? waves hands some more
from hammerspoon.
Describe "just sits there"... is the console accessible, but just doesn't take input? pop up a dialog that won't go away? Or maybe better, what typo should I introduce to reproduce the effect myself?
I ask because I have had weird issues creating some of my previous modules in which error catching and providing bail outs was highly dependent upon the order in which certain things occurred, and I want to see if I can figure out what minimally MUST work to get usable error messages and/or make the situation recoverable (assuming you know what you're doing).
from hammerspoon.
If you cause some part of setup.lua to want to throw an exception, nothing seems to handle it and the app gets a bit stuck and may also crash entirely.
from hammerspoon.
Most likely it comes down to one of two possibilities:
- it's a syntax error, and then line 92 in MJLua.m is your likely culprit: luaL_loadfile(L, [[[NSBundle mainBundle] pathForResource:@"setup" ofType:@"lua"] fileSystemRepresentation]);
If an error in parsing occurs, it's return code isn't LUA_OK, then what it pushes onto the stack is a string (the error) and not a function, so the eventual lua_pcall fails, and again, no check for the results is done.
Not much we can do with the console at this point, but we could pop up a nsalert and exit gracefully, rather than crash.
- it's a logic/programming error, and then what I posted above might apply...
Here, the console might be usable if at least the print global has been dealt with.
I can try and come up with some example cases and test this theory later, if you like.
from hammerspoon.
I've pushed up 0b027f8 to refuse to proceed starting the app if setup.lua can't be opened or parsed.
The logic/programming error case is much trickier to deal with. I suppose it's possible that somehow setup.lua/init.lua ends up stuck in a loop and there's not a huge amount we can do about it, short of spawning a watchdog thread that circles back and kills the app if it hasn't initialised in a reasonable amount of time.
from hammerspoon.
@Habbie Do you think that 2) outlined by @asmagill needs any attention here? I'm not sure there's much we can reasonably do to defend against logic errors (like infinite loops) in peoples' init.lua. We're covered against syntax errors in setup.lua now. Do we think that is sufficient to close out this issue?
from hammerspoon.
I presume we are also covered against syntax errors in init.lua now?
For loops and such, I don't have better ideas than watchdog-like things. May want to file that separately, not sure it's necessary for 1.0
from hammerspoon.
I think we were always covered against syntax errors in init.lua
from hammerspoon.
I believe so as well!
from hammerspoon.
Cool, then I shall close this issue. We can revisit the halting problem later, if it becomes important, but ultimately it's going to be nigh on impossible to solve completely, IMO.
from hammerspoon.
Related Issues (20)
- Feature Request: I would like to know if a modal is in the state active HOT 1
- Feature request: `:keydown` callback for `hs.chooser`
- Delete Preferences modal is confusing
- Moving Apps To Spaces HOT 2
- Memory is growing up to 2-4GB after some time - how to debug? HOT 1
- ** Warning: LuaSkin: hs.audiodevice.watcher callback fired, but theWatcher is nil. This is a bug
- ERROR: hotkey.lua:415: key must be a string or a number HOT 6
- Create Helper apps with Hammerspoon and sell it? HOT 2
- attempt to call a nil value (method 'setCallback')
- A way to prevent hs.alert.show() from stealing focus? HOT 1
- Unexpected behavior when moving a window with `moveToUnit` HOT 2
- hs.window:raise() focuses raised window when other window for same application is focused HOT 1
- hs.window.filter stops emitting windowFocused events for application if one window has tabs HOT 1
- Add functions to hs.mouse to get more information about cursor type HOT 1
- hs.notify.show doesn't work HOT 2
- Support for Elgato Stream Deck Neo HOT 1
- hs.serial:sendData(value) chokes after some indeterminate amount of time? HOT 2
- hs.socket and hs.socket.udp listens on all interfaces
- hs.spaces.moveWindowToSpace not working HOT 3
- `hs.alert.defaultStyle`: option to add top or bottom margin
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hammerspoon.