mirror of
https://gitlab.com/RemixDev/deezer-js.git
synced 2024-12-28 02:16:18 +00:00
Fixed recursion in api calls
This commit is contained in:
parent
ad5e45f72e
commit
97231d29d3
|
@ -49,8 +49,10 @@ class API{
|
||||||
}).json()
|
}).json()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.debug("[ERROR] deezer.api", method, args, e.name, e.message)
|
console.debug("[ERROR] deezer.api", method, args, e.name, e.message)
|
||||||
// await new Promise(r => setTimeout(r, 2000)) // sleep(2000ms)
|
if (["ECONNABORTED", "ECONNREFUSED", "ECONNRESET", "ENETRESET", "ETIMEDOUT"].includes(e.code)){
|
||||||
// return this.api_call(method, args)
|
await new Promise(r => setTimeout(r, 2000)) // sleep(2000ms)
|
||||||
|
return this.api_call(method, args)
|
||||||
|
}
|
||||||
throw new APIError(`${method} ${args}:: ${e.name}: ${e.message}`)
|
throw new APIError(`${method} ${args}:: ${e.name}: ${e.message}`)
|
||||||
}
|
}
|
||||||
if (result_json.error){
|
if (result_json.error){
|
||||||
|
|
|
@ -64,8 +64,10 @@ class GW{
|
||||||
}).json()
|
}).json()
|
||||||
}catch (e){
|
}catch (e){
|
||||||
console.debug("[ERROR] deezer.gw", method, args, e.name, e.message)
|
console.debug("[ERROR] deezer.gw", method, args, e.name, e.message)
|
||||||
// await new Promise(r => setTimeout(r, 2000)) // sleep(2000ms)
|
if (["ECONNABORTED", "ECONNREFUSED", "ECONNRESET", "ENETRESET", "ETIMEDOUT"].includes(e.code)){
|
||||||
// return this.api_call(method, args, params)
|
await new Promise(r => setTimeout(r, 2000)) // sleep(2000ms)
|
||||||
|
return this.api_call(method, args)
|
||||||
|
}
|
||||||
throw new GWAPIError(`${method} ${args}:: ${e.name}: ${e.message}`)
|
throw new GWAPIError(`${method} ${args}:: ${e.name}: ${e.message}`)
|
||||||
}
|
}
|
||||||
if (result_json.error.length) throw new GWAPIError(result_json.error)
|
if (result_json.error.length) throw new GWAPIError(result_json.error)
|
||||||
|
|
Loading…
Reference in a new issue