diff options
author | Dhruv Srivastava <dhruvsri@google.com> | 2020-11-04 14:19:59 +0100 |
---|---|---|
committer | Luca Milanesio <luca.milanesio@gmail.com> | 2020-11-10 16:59:51 +0000 |
commit | 35c4262b51d8cefb1f3e6bfbfe94af82d5e85962 (patch) | |
tree | be9339e8e7ef14b3ebe1918b906a1ea5144ef4b1 | |
parent | b465ff49d71fad4de9a215ef5212cd4d3cf47a4a (diff) |
Catch errors in getPortedComments request
Canary seems to be throwing 500 on getPortedComments request.
Do now show an error modal and log error.
Change-Id: I603a245aa26700b7b0e5e8de50e2b2b7c1f5f861
-rw-r--r-- | polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.ts | 12 | ||||
-rw-r--r-- | polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface_test.js | 12 |
2 files changed, 24 insertions, 0 deletions
diff --git a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.ts b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.ts index 8e90c383ea..724de9c8ce 100644 --- a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.ts +++ b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.ts @@ -2799,10 +2799,16 @@ export class GrRestApiInterface changeNum: NumericChangeId, revision: RevisionId ): Promise<PathToCommentsInfoMap | undefined> { + // maintaining a custom error function so that errors do not surface in UI + const errFn: ErrorCallback = (response?: Response | null) => { + if (response) + console.info(`Fetching ported comments failed, ${response.status}`); + }; return this._getChangeURLAndFetch({ changeNum, endpoint: '/ported_comments/', revision, + errFn, }); } @@ -2810,10 +2816,16 @@ export class GrRestApiInterface changeNum: NumericChangeId, revision: RevisionId ): Promise<PathToCommentsInfoMap | undefined> { + // maintaining a custom error function so that errors do not surface in UI + const errFn: ErrorCallback = (response?: Response | null) => { + if (response) + console.info(`Fetching ported drafts failed, ${response.status}`); + }; return this._getChangeURLAndFetch({ changeNum, endpoint: '/ported_drafts/', revision, + errFn, }); } diff --git a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface_test.js b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface_test.js index 505fd58f2b..9c21899ab3 100644 --- a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface_test.js +++ b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface_test.js @@ -21,6 +21,7 @@ import {mockPromise} from '../../../test/test-utils.js'; import {GrReviewerUpdatesParser} from './gr-reviewer-updates-parser.js'; import {ListChangesOption} from '../../../utils/change-util.js'; import {appContext} from '../../../services/app-context.js'; +import {createChange} from '../../../test/test-data-generators.js'; const basicFixture = fixtureFromElement('gr-rest-api-interface'); @@ -1343,6 +1344,17 @@ suite('gr-rest-api-interface tests', () => { assert.isTrue(handler.calledOnce); }); + test('ported comment errors do not trigger error dialog', () => { + const change = createChange(); + const dispatchStub = sinon.stub(element._restApiHelper, 'dispatchEvent'); + sinon.stub(element._restApiHelper, 'fetchJSON').returns(Promise.resolve({ + ok: false})); + + element.getPortedComments(change._number, 'current'); + + assert.isFalse(dispatchStub.called); + }); + test('saveChangeStarred', async () => { sinon.stub(element, 'getFromProjectLookup') .returns(Promise.resolve('test')); |