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

Error message JSON path fixes in Editor Angular Controllers #6029

Merged

Conversation

wangf1122
Copy link
Contributor

@wangf1122 wangf1122 commented Nov 8, 2021

Issue Description:

The exception thrown in metadata editor/editorBoard was not captured the correct returned JSON path. The example JSON looks like. It should be reason.data->{code, description, message}. There is an unknown "error" object in the controller.

image

There is no specific way to reproduce such exception. The exception can happens randomly for example, the backend store throws timeout or service not available. But there is some workaround to reproduce such issue. Go to this line of code

boolean approved=true;
if (metadata instanceof MetadataDraft) {
approved=false;
}

Place manual exception throwing code:
image

Build your project and go to editor board and delete any records:
image

Since there is forced exception throwing in the API, so an error response will be returned to the browser.

image

But the delete icon will keep spinning and no error message returned.

After the fix, the error message should be look like this:
image

There was a fix in one of the previous PR #5079 but this PR is not meant for backporting to 3.12 as there are problems when doing cherry pick. So I created this PR in order to backport partial of its solution into 3.12.

As this PR changed EditorController.js which will fix another place for unrecognized returned JSON in newly created record when exception happens:

image

After the fix:
image

@wangf1122 wangf1122 marked this pull request as ready for review November 8, 2021 23:56
title: $translate.instant(reason.data.error.message),
error: reason.data.error.description,
title: reason.data.message, //returned error JSON obj
error: reason.data.description,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To confirm: has the code been reviewed to verify reason.data.error.message and reason.data.error.description are not used?

Otherwise, I would used the new properties as a fallback if the original ones are not returned.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@josegar74

The "reason.data.error.message" and "reason.data.error.description" are not used for this Angular module. I don't think it's a property but it's a JSON returned from the API side.

@josegar74 josegar74 merged commit ebfa46b into geonetwork:main Dec 20, 2021
@wangf1122
Copy link
Contributor Author

@josegar74 Would you backport this to 3.12 please? Thanks

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

Successfully merging this pull request may close these issues.

None yet

2 participants