• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Where did my assert go?

Explorer ,
Mar 19, 2017 Mar 19, 2017

Copy link to clipboard

Copied

I'm having problems with error dialogs inside of event handlers (excuse me if that's not the vernacular used for LUA/LR). The code below opens a dialog with a single button which causes an assert(false) condition. Inside the handler, there is no error message box displayed. Outside the handler, an error message is displayed. I've tried calling LrDialogs.attachErrorDialogToFunctionContext with no change and I also tried wrapping showCustomDialog and the anonymous action with John R. Ellis's showErrors and still do not get an error message.

What am I missing?

-- required imports

local LrDialogs = import "LrDialogs"

local LrTasks = import "LrTasks"

local LrView = import "LrView"

local LrFunctionContext = import "LrFunctionContext"

local function showCustomDialog()

  LrFunctionContext.callWithContext(

  "showCustomDialog",

  function( context )

  -- This assert will show a dialog

  -- assert(false,"false assertion")

  local viewFactory = LrView.osFactory()

  local content = viewFactory:push_button

  {

  title = "Push Me",

  action = function()

  -- this does not show a dialog

  assert(false,"false assertion")

  end

  }

  LrDialogs.presentFloatingDialog(

  _PLUGIN,

  {

  title = "My Dialog",

  contents = content,

  }

  )

  end)

end

LrTasks.startAsyncTask(showCustomDialog)

TOPICS
SDK

Views

355

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Mar 19, 2017 Mar 19, 2017

When I wrap the functions passed to the SDK with Debug.showErrors(), the assertion error is trapped by Debug:

local Require = require 'Require'.path ("../common").reload ()

local Debug = require 'Debug'.init ()

require 'strict'

local LrDialogs = import "LrDialogs"

local LrFunctionContext = import "LrFunctionContext"

local LrTasks = import "LrTasks"

local LrView = import "LrView"

local showErrors = Debug.showErrors

local function showCustomDialog()

    LrFunctionContext.callWithContext ("showCustomDialog",

...

Votes

Translate

Translate
LEGEND ,
Mar 19, 2017 Mar 19, 2017

Copy link to clipboard

Copied

When I wrap the functions passed to the SDK with Debug.showErrors(), the assertion error is trapped by Debug:

local Require = require 'Require'.path ("../common").reload ()

local Debug = require 'Debug'.init ()

require 'strict'

local LrDialogs = import "LrDialogs"

local LrFunctionContext = import "LrFunctionContext"

local LrTasks = import "LrTasks"

local LrView = import "LrView"

local showErrors = Debug.showErrors

local function showCustomDialog()

    LrFunctionContext.callWithContext ("showCustomDialog",

    showErrors (function( context )

        local viewFactory = LrView.osFactory()

        local content = viewFactory:push_button {title = "Push Me",

            action = showErrors (function()

                assert (false, "false assertion")

                end)}

        LrDialogs.presentFloatingDialog (_PLUGIN, {title = "My Dialog",

            contents = content})

        end))

    end

LrTasks.startAsyncTask (showErrors (showCustomDialog))

I'm using the most recent version of the debugging toolkit, but I'm sure that the old version would also trap the error.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 19, 2017 Mar 19, 2017

Copy link to clipboard

Copied

Thanks John!  I'm not exactly sure what was happening. I'm not able to reproduce what I saw (or I think I saw). I also started hitting an error that closeWindow was being called on a nil window. A restart of lightroom seems to have corrected that.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 19, 2017 Mar 19, 2017

Copy link to clipboard

Copied

LATEST

I've found restarting LR and going to bed often solves mysterious LR problems...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines