Request to make "Problem with Plugin at Path: ... (!PrincipalClass)" error more descriptive

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 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?

I agree that sometimes the console logs are non descriptive and then it’s hard to debug.

But do you actually try to catch possible errors inside your plugin code? I can recommend doing this everywhere. My favourite one is the one, Geeorg showed me once:

import traceback
  print traceback.format_exc()

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.

1 Like

Neat, didn’t know about the traceback package.

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.

Yea, I wonder if this isn’t the Objective C wrapper sort of bailing out on what it’s being fed from a plugin it’s trying to parse and plug into the main app.

Did you set the PrincipalClass in the info.plist correctly? And did you check the

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.

I see what I can do. Can you send me the failing plugin?

Literally any syntax error in a 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.

I had a look at this. Unfortunately, I can’t do much better right now. But the macro window should have some info already.

1 Like

Roger, thanks for investigating! Have a good week :wink: