I’m on version 2.5.b (1123) and tried updating a plugin of mine with a couple of lines of code. Apparently something is amiss, since the plugin fails to load. In the console log the error message I get is:
Problem with Plugin at Path: /Users/johannes/Library/Application Support/Glyphs/Repositories/SyncMetricsKeys/SyncMetricsKeys.glyphsPlugin (!PrincipalClass)
Now, after a lot of searching I found what is inevitably a stupid mistake of using a “,” where a “%” should have been, and I figured it out from simply attempting to run the plugin.py from the terminal (which is otherwise non-sensical, so it wasn’t the first thing that came to my mind), which then gave the obvious syntax error warning.
My point is I’ve spend nearly an hour restarting Glyphs checking what changes in my code could be so offensive that the plugin is refused to load. Instead of the ominous (!PrincipalClass) could Glyphs output a more descriptive error message when a plugin fails to load altogehter?
If you’re escaping possible errors, usually the plugins will at least load and try to do as much as they can and once they stumble over the error, it will tell you in the macro panel. Or in the system console, if you use the console log instead.
And sure, generally error handling should be used. In this case though there was nothing to handle, since the plugin doesn’t even load in. It makes me wonder if that particular !PrincipalClass error message always points to a fatal syntax error (in which case the error message could be improved), or if it’s some catch all?
I can imagine that it does this in those cases where another compiler would also stop immediately from executing if there is a syntax error. Python doesn’t forgive those, other than runtime errors or semantical errors. But I’m not exactly sure.
Yes and yes. As mentioned, a simple syntax error was what caused this problem. I am merely asking if there is some way of, for example, accessing the python interpreter’s error messages instead of simply failing to load the class altogether.
Literally any syntax error in a plugin.py will do and result in the ominous !PrincipalClass error message, just add a comma after the plugin class definition.
Admittedly a proper IDE instead of just my text editor would have detected the syntax error. I had copied working code from the Macro window to the plugin, added a debug print statement (in which I had my stupid syntax error), and when the class failed to load I tried to check what in my code would work in the Macro window but not as part of the plugin. It would be an easy-peasy mistake to spot had the same syntax error warning the CLI interpreter gives popped have popped up in the console log.