Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-22988

More dev friendly info on UnauthorizedException

    Details

      Description

      When an UnauthorizedException is thrown by content service, the only message is:
      User does not have access to 'read' 'content'
      since the call is done with:
      throw new UnauthorizedException( 'content', 'read' );

      the message could be improved, passing extra information when throwing the exception, making use of the extra parameters accepted by
      UnauthorizedException::__construct( $module, $function, array $properties = null, Exception $previous = null )

        Issue Links

          Activity

          Hide
          Gaetano Giunta (Inactive) added a comment -

          This is in general true for the rest of API as well - there are many exceptions which could be more detailed.

          I'll try to remember to list them here as soon as I stumble upon them...

          Show
          Gaetano Giunta (Inactive) added a comment - This is in general true for the rest of API as well - there are many exceptions which could be more detailed. I'll try to remember to list them here as soon as I stumble upon them...
          Hide
          Gareth Arnott added a comment -

          Could not find 'content/location' with identifier "" is one that springs to mind.

          When you search for content/location by id, but the id is not valid (e.g. came from an outdated solr record), the message is not too helpful.

          Show
          Gareth Arnott added a comment - Could not find 'content/location' with identifier "" is one that springs to mind. When you search for content/location by id, but the id is not valid (e.g. came from an outdated solr record), the message is not too helpful.
          Hide
          André Rømcke added a comment -

          Work in progress PR for UnauthorizedException changes: https://github.com/ezsystems/ezpublish-kernel/pull/902
          NotFoundException messages like mentioned by Gareth not covered yet.

          Show
          André Rømcke added a comment - Work in progress PR for UnauthorizedException changes: https://github.com/ezsystems/ezpublish-kernel/pull/902 NotFoundException messages like mentioned by Gareth not covered yet.
          Hide
          André Rømcke added a comment -

          > When you search for content/location by id, but the id is not valid (e.g. came from an outdated solr record), the message is not too helpful.

          ok, so search via ezfind and then attempt to retrieve the content?

          Show
          André Rømcke added a comment - > When you search for content/location by id, but the id is not valid (e.g. came from an outdated solr record), the message is not too helpful. ok, so search via ezfind and then attempt to retrieve the content?
          Hide
          Gareth Arnott added a comment -

          ok, so search via ezfind and then attempt to retrieve the content?

          Retrieving the objects is too much of a performance hit for us, we have to set asObjects = false on as many fetches as possible

          Show
          Gareth Arnott added a comment - ok, so search via ezfind and then attempt to retrieve the content? Retrieving the objects is too much of a performance hit for us, we have to set asObjects = false on as many fetches as possible
          Hide
          Gareth Arnott added a comment -

          Another couple of messages which could be more useful: (I think these might be bugs)

           
          // SearchHandlerInterface->Handler->findSingle()
           
                  if ( !$result->totalCount )
                      throw new NotFoundException( 'Content', "findSingle() found no content for given \$criterion" );
                  else if ( $result->totalCount > 1 )
                      throw new InvalidArgumentException( "totalCount", "findSingle() found more then one item for given \$criterion" );

          Show
          Gareth Arnott added a comment - Another couple of messages which could be more useful: (I think these might be bugs)   // SearchHandlerInterface->Handler->findSingle()   if ( !$result->totalCount ) throw new NotFoundException( 'Content', "findSingle() found no content for given \$criterion" ); else if ( $result->totalCount > 1 ) throw new InvalidArgumentException( "totalCount", "findSingle() found more then one item for given \$criterion" );
          Hide
          André Rømcke added a comment - - edited

          Merged in https://github.com/ezsystems/ezpublish-kernel/commit/f2f0b3ffb69aae41c6572edaebd5514a037635be

          @Gareth: In the end I kept this to original scope and did not do anything in regards to NotFound, the issue you refer to should be reported separately with full stack trace, cause as you say it hints about some identifier being empty for different issues then the throw code themselves which was the focus here.

          Show
          André Rømcke added a comment - - edited Merged in https://github.com/ezsystems/ezpublish-kernel/commit/f2f0b3ffb69aae41c6572edaebd5514a037635be @Gareth: In the end I kept this to original scope and did not do anything in regards to NotFound, the issue you refer to should be reported separately with full stack trace, cause as you say it hints about some identifier being empty for different issues then the throw code themselves which was the focus here.
          Hide
          Pedro Resende (Inactive) added a comment -

          Tested and approved by Q.A.

          Show
          Pedro Resende (Inactive) added a comment - Tested and approved by Q.A.

            People

            • Assignee:
              Unassigned
              Reporter:
              Paulo Bras (Inactive)
            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: