openvidu-node-client: Updated rejected responses and dependencies

Old promises rejections return unusable responses to the client. Now they return the status code
pull/730/head
csantosm 2022-05-26 13:42:58 +02:00
parent 75f4c6497f
commit df7bd5f202
3 changed files with 906 additions and 792 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +1,25 @@
{ {
"author": "OpenVidu", "author": "OpenVidu",
"dependencies": { "dependencies": {
"axios": "0.21.4", "axios": "0.27.2",
"buffer": "6.0.3" "buffer": "6.0.3"
}, },
"description": "OpenVidu Node Client", "description": "OpenVidu Node Client",
"devDependencies": { "devDependencies": {
"@types/node": "14.14.37", "@types/node": "17.0.35",
"grunt": "1.3.0", "grunt": "1.5.3",
"grunt-cli": "1.4.2", "grunt-cli": "1.4.3",
"grunt-contrib-copy": "1.0.0", "grunt-contrib-copy": "1.0.0",
"grunt-contrib-sass": "2.0.0", "grunt-contrib-sass": "2.0.0",
"grunt-contrib-uglify": "5.0.1", "grunt-contrib-uglify": "5.2.1",
"grunt-contrib-watch": "1.1.0", "grunt-contrib-watch": "1.1.0",
"grunt-postcss": "0.9.0", "grunt-postcss": "0.9.0",
"grunt-string-replace": "1.3.1", "grunt-string-replace": "1.3.1",
"grunt-ts": "6.0.0-beta.22", "grunt-ts": "6.0.0-beta.22",
"ts-node": "9.1.1", "ts-node": "10.8.0",
"tslint": "6.1.3", "tslint": "6.1.3",
"typedoc": "0.19.2", "typedoc": "0.22.15",
"typescript": "3.8.3" "typescript": "4.0.8"
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"main": "lib/index.js", "main": "lib/index.js",

View File

@ -196,7 +196,7 @@ export class OpenVidu {
resolve(r); resolve(r);
} else { } else {
// ERROR response from openvidu-server. Resolve HTTP status // ERROR response from openvidu-server. Resolve HTTP status
reject(new Error(res.status.toString())); reject(res.status);
} }
}).catch(error => { }).catch(error => {
this.handleError(error, reject); this.handleError(error, reject);
@ -239,7 +239,7 @@ export class OpenVidu {
resolve(r); resolve(r);
} else { } else {
// ERROR response from openvidu-server. Resolve HTTP status // ERROR response from openvidu-server. Resolve HTTP status
reject(new Error(res.status.toString())); reject(res.status);
} }
}).catch(error => { }).catch(error => {
this.handleError(error, reject); this.handleError(error, reject);
@ -274,7 +274,7 @@ export class OpenVidu {
resolve(new Recording(res.data)); resolve(new Recording(res.data));
} else { } else {
// ERROR response from openvidu-server. Resolve HTTP status // ERROR response from openvidu-server. Resolve HTTP status
reject(new Error(res.status.toString())); reject(res.status);
} }
}).catch(error => { }).catch(error => {
this.handleError(error, reject); this.handleError(error, reject);
@ -311,7 +311,7 @@ export class OpenVidu {
resolve(recordingArray); resolve(recordingArray);
} else { } else {
// ERROR response from openvidu-server. Resolve HTTP status // ERROR response from openvidu-server. Resolve HTTP status
reject(new Error(res.status.toString())); reject(res.status);
} }
}).catch(error => { }).catch(error => {
this.handleError(error, reject); this.handleError(error, reject);
@ -346,7 +346,7 @@ export class OpenVidu {
resolve(undefined); resolve(undefined);
} else { } else {
// ERROR response from openvidu-server. Resolve HTTP status // ERROR response from openvidu-server. Resolve HTTP status
reject(new Error(res.status.toString())); reject(res.status);
} }
}).catch(error => { }).catch(error => {
this.handleError(error, reject); this.handleError(error, reject);
@ -416,7 +416,7 @@ export class OpenVidu {
resolve(hasChanged); resolve(hasChanged);
} else { } else {
// ERROR response from openvidu-server. Resolve HTTP status // ERROR response from openvidu-server. Resolve HTTP status
reject(new Error(res.status.toString())); reject(res.status);
} }
}).catch(error => { }).catch(error => {
this.handleError(error, reject); this.handleError(error, reject);
@ -573,7 +573,7 @@ export class OpenVidu {
resolve({ changes: globalChanges, sessionChanges }); resolve({ changes: globalChanges, sessionChanges });
} else { } else {
// ERROR response from openvidu-server. Resolve HTTP status // ERROR response from openvidu-server. Resolve HTTP status
reject(new Error(res.status.toString())); reject(res.status);
} }
}).catch(error => { }).catch(error => {
this.handleError(error, reject); this.handleError(error, reject);
@ -602,15 +602,15 @@ export class OpenVidu {
handleError(error: AxiosError, reject: (reason?: any) => void) { handleError(error: AxiosError, reject: (reason?: any) => void) {
if (error.response) { if (error.response) {
// The request was made and the server responded with a status code (not 2xx) // The request was made and the server responded with a status code (not 2xx)
reject(new Error(error.response.status.toString())); reject(error.response.status);
} else if (error.request) { } else if (error.request) {
// The request was made but no response was received // The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js // http.ClientRequest in node.js
reject(new Error(error.request)); reject(error.request);
} else { } else {
// Something happened in setting up the request that triggered an Error // Something happened in setting up the request that triggered an Error
reject(new Error(error.message)); reject(error.message);
} }
} }