Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZP-24851: CAPI to display server provided error message if it is sent #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

janit
Copy link
Member

@janit janit commented Apr 18, 2016

Partial fix for EZP-24851, attempts to set error message to server provided one - if it is set as described in https://jira.ez.no/browse/EZP-24853:

{
    "ErrorMessage": {
        "_media-type": "application\/vnd.ez.api.ErrorMessage+json",
        "errorCode": 400,
        "errorMessage": "Bad Request",
        "errorDescription": "Value for required field definition 'user_account' with language 'eng-GB' is empty",
        "trace": "<stack trace>",
        "file": "\/home\/dp\/dev\/ezplatform\/vendor\/ezsystems\/ezpublish-kernel\/eZ\/Publish\/Core\/REST\/Server\/Controller\/Content.php",
        "line": 248
    }
}

@andrerom
Copy link
Contributor

cool :)

@andrerom
Copy link
Contributor

ping @dpobel this is about to become part of customer request (issue).

@dpobel
Copy link
Contributor

dpobel commented Apr 20, 2016

This change is not really needed because even in case of error we always provide the response object where the error message is available (like any element in the response). So basically, in your callback you can always write something like:

contentService.loadLocation(locationId, function (error, response) {
    if ( error ) {
        console.log(response.document.errorMessage.errorDescription);
    }
});

@andrerom
Copy link
Contributor

andrerom commented Apr 20, 2016

but isn't something ala what proposed here about making sure it always displays in the dev toolbar?

@dpobel
Copy link
Contributor

dpobel commented Apr 20, 2016

@andrerom not sure to fully understand your comment. What is "the dev toolbar" ? As far as I know, the CAPIError message is not really used any where.

@andrerom
Copy link
Contributor

network tab in browser developer tools, the only place to know what goes wrong with this next gen UI ;)

@janit
Copy link
Member Author

janit commented Apr 20, 2016

The CAPI error message can pop up as a fallback. In this specific case when developer validating on server side, it fails and shows the standard error message - even though the response contains the errorDescription in JSON that could be displayed.

@dpobel
Copy link
Contributor

dpobel commented Apr 21, 2016

network tab in browser developer tools, the only place to know what goes wrong with this next gen UI ;)

ahah :) but the network tab only cares about the actual server response, not how we create an Error object and so on. So this patch does not change anything there.

The CAPI error message can pop up as a fallback. In this specific case when developer validating on server side, it fails and shows the standard error message - even though the response contains the errorDescription in JSON that could be displayed.

where does that happen ? if it's in PlatformUI, this should be fixed there as choosing the error message from the Response (or building the message differently) over the one provided by the Error message is an app decision, not a REST Client decision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants