Skip to content

Commit

Permalink
Return nil from API :new if no accessToken
Browse files Browse the repository at this point in the history
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.

Fixes #14
  • Loading branch information
rcloran committed Nov 7, 2023
1 parent f39fc4a commit 8ce8ece
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lr-inaturalist-publish.lrdevplugin/INaturalistAPI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8ce8ece

Please sign in to comment.