From c2335010682d0b5d10aaa2b133b281e1ccb32bc4 Mon Sep 17 00:00:00 2001 From: Russell Cloran Date: Tue, 7 Nov 2023 09:47:50 -0800 Subject: [PATCH] Return nil from API :new if no accessToken This will cause errors in other parts of the program to be thrown earlier, for "attempt to index local 'api' (a nil value)". Importantly, it happens early enough that the progress meter is not set up yet, and so the user is not stuck in a state where they can't close the sync. The error message is still not pretty, but this is a path that should not happen -- an access token should always be available. --- lr-inaturalist-publish.lrdevplugin/INaturalistAPI.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lr-inaturalist-publish.lrdevplugin/INaturalistAPI.lua b/lr-inaturalist-publish.lrdevplugin/INaturalistAPI.lua index fd2ffbe..ab07dc3 100644 --- a/lr-inaturalist-publish.lrdevplugin/INaturalistAPI.lua +++ b/lr-inaturalist-publish.lrdevplugin/INaturalistAPI.lua @@ -23,6 +23,9 @@ function INaturalistAPI:new(login, accessToken) setmetatable(o, { __index = self }) if login and not accessToken then accessToken = LrPasswords.retrieve(login) + if not accessToken then + return nil + end end o.accessToken = accessToken return o