Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-142748

Error callback of javascript method Liferay.Service is never invoked

    Details

      Description

      The javascript method Liferay.Service for calling remote services has four arguments. With the last argument you can pass an error callback which should be triggered whenever the status code of the ajax request is >= 400. This actually never happens. The success callback is always used.

      Steps to reproduce:

      1. Choose an arbitrary liferay remote service (e.g. GroupServiceImpl)
      2. Trigger a method via javascript that causes an exception, for example:
        Liferay.Service(
          '/group/get-group',
          {
            groupId: 123
          },
          function(response) {
            console.log('success')
          },
          function(error) {
            console.log('error')
          },
        );
        

      Expected behaviour:
      The error callback should be invoked since no group with groupId 123 exists and the status code of the response is 404.

      Actual behaviour:
      The success callback is invoked.

      It's pretty obvious that the incorrect code can be found here: modules\apps\frontend-js\frontend-js-web\src\main\resources\META-INF\resources\liferay\liferay.js. In the success callback of the method Liferay.Util.fetch there is a missing check for response.ok which you should normally do when using the fetch api.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              summer.zhang Summer Zhang
              Reporter:
              prof-schnitzel Matthew K
              Participants of an Issue:
              Recent user:
              Norbert Németh
              Engineering Assignee:
              Krešimir Čoko
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                23 weeks, 3 days ago

                  Packages

                  Version Package
                  7.4.3.8 CE GA8
                  7.4.13 DXP U4
                  Master