fix: handle rejected help requests
What does this MR do and why?
Fixes an issue where the Request help action on the Manage Merge Request page fails to emit an error when the API request is rejected.
Previously, Axios rejected non-2xx responses (such as HTTP 403), causing the request to exit before reaching the existing error-handling logic. As a result, the error event was never emitted.
This MR wraps the API request in a try/catch block and emits the error event when the request is rejected. It also preserves the existing behavior of redirecting after a successful response.
Closes #958 (closed)
Design and production fit
- Handles rejected Axios requests gracefully.
- Preserves existing behavior for successful requests.
- Emits the
errorevent for both rejected requests and unsuccessful response statuses. - Adds regression coverage for rejected API requests.
Screenshots or screen recordings
Not applicable. This change affects request error handling and does not introduce UI changes.
Before
The rejected API request was not handled, and the error event was not emitted.
After
Rejected API requests are caught, and the error event is emitted.
Validation steps
- Run the
HelpActioncomponent tests:
yarn test app/javascript/common/components/HelpAction.spec.js - Verify that all 6 tests pass.
- Run ESLint on
HelpAction.vueandHelpAction.spec.js. - Verify
git diff --checkpasses.
Validation completed:
- 6/6 tests passed.
- ESLint passed.
git diff --checkpassed.