Problem/Motivation

Error messages on generating alt text are not displayed within the dialog but are displayed on the main page. This made the alt-text generation look like a no operation because the error message was only visible after closing the dialog.
See the SS:-
alt

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

utkarsh_33 created an issue. See original summary.

utkarsh_33’s picture

Status: Active » Needs review
narendrar’s picture

Status: Needs review » Needs work

By this change, message display on normal page breaks. Moving it to NW again.

narendrar’s picture

GenerateAltText.php does not have exception handling.
To get actual exception message, may be we could do something like:

    try {
      $output = $provider->chat($input, $model);
      $alt_text = $output->getNormalized()->getText();
      return new JsonResponse([
        'alt_text' => $alt_text,
      ]);
    }
    catch (\Exception $e) {
      return new JsonResponse([
        'error' => $e->getMessage(),
      ], 500);
    }

Or If we want to handle specific Exceptions, that can also be done here.

utkarsh_33’s picture

Status: Needs work » Needs review
StatusFileSize
new237.1 KB
new248.85 KB

Now with the above changes it would also display the reason for the errors.
Attaching the SS for both with and without modal cases.

kunal.sachdev’s picture

Status: Needs review » Reviewed & tested by the community

I tested this and it works as expected!!

marcus_johansson’s picture

Status: Reviewed & tested by the community » Fixed

Thank you, I also tested it and got it working.

Getting merged.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.