Skip to content

Commit

Permalink
Merge pull request #660 from Travelport-Ukraine/master
Browse files Browse the repository at this point in the history
0.17.1 Hotfix for `uapiErrorHandler`
  • Loading branch information
dchertousov authored Jun 28, 2024
2 parents 126057f + a491a0e commit 446ca3a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions docs/Terminal.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ on how to use emulation.
In case you want to handle some specific errors from uAPI, you can provde `uapiErrorHandler` function
in options.

Function should return response from retried command or any other command.

Footprint of the functions should be as follows:
```javascript
async (
executeCommandWithRetry,
{ command, error: err }
) => {
// your code goes here
// response is an array of strings (lines of terminal response)
return response;
}
```

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uapi-json",
"version": "1.17.0",
"version": "1.17.1",
"description": "Travelport Universal API",
"main": "src/",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Terminal/Terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ module.exports = function (settings) {
} catch (e) {
if (!isErrorRetriable(e) || times <= 0) {
if (uapiErrorHandler) {
await uapiErrorHandler(
return uapiErrorHandler(
executeCommandWithRetry,
{ command, error: e }
);
Expand Down
6 changes: 4 additions & 2 deletions test/Terminal/Terminal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,14 @@ describe('#Terminal', function terminalTest() {
});
});
});
describe('Handling uapi errors', () => {
describe.only('Handling uapi errors', () => {
beforeEach(() => {
// Resetting spies
getSessionToken.resetHistory();
executeCommandOk.resetHistory();
closeSession.resetHistory();
erIssues.resetHistory();
executeCommandErIssues.resetHistory();
});
it('should fail if no handlers provided', async () => {
const uAPITerminal = terminalErIssues({
Expand Down Expand Up @@ -354,7 +356,7 @@ describe('#Terminal', function terminalTest() {
faultstring: 'String index out of range: 6',
});

await executeCommandWithRetry(command, 0);
return executeCommandWithRetry(command, 0);
},
}
});
Expand Down

0 comments on commit 446ca3a

Please sign in to comment.