How to use the GatewayTimeout function from http-errors
Find comprehensive JavaScript http-errors.GatewayTimeout code examples handpicked from public code repositorys.
150 151 152 153 154 155 156 157 158 159
serviceUnavailable: function serviceUnavailable (message) { return new createError.ServiceUnavailable(message) }, gatewayTimeout: function gatewayTimeout (message) { return new createError.GatewayTimeout(message) }, httpVersionNotSupported: function httpVersionNotSupported (message) { return new createError.HTTPVersionNotSupported(message)
30
340
17
+ 55 other calls in file
208 209 210 211 212 213 214 215 216 217
function waitFor (condition, { timeout = 5000 } = {}) { const watch = this const resourceName = this.resourceName return new Promise((resolve, reject) => { const timeoutId = setTimeout(() => { done(new GatewayTimeout(`Resource "${resourceName}" could not be initialized within ${timeout} ms`)) }, timeout) function done (err, obj) { clearTimeout(timeoutId)
87
0
1
114 115 116 117 118 119 120 121 122 123
this.request.log.warn(err, 'response errored') if (!this.sent) { if (err.code === 'ERR_HTTP2_STREAM_CANCEL' || err.code === 'ENOTFOUND') { onError(this, { error: new createError.ServiceUnavailable() }) } else if (err instanceof TimeoutError || err.code === 'UND_ERR_HEADERS_TIMEOUT') { onError(this, { error: new createError.GatewayTimeout() }) } else { onError(this, { error: createError(500, err) }) } }
67
0
0
5 6 7 8 9 10 11 12 13 14
try { return await fn(...args); } catch (error) { // Failed request if (error.name === 'FetchError' && error.code === 'ETIMEDOUT') { throw createError.GatewayTimeout(); } // Telegram error if (error.response && error.response.ok === false && error.response.description) {
1
3
1
173 174 175 176 177 178 179 180 181 182
module.exports.UnavailableForLegalReasons = new HTTPErrors.UnavailableForLegalReasons() module.exports.InternalServerError = new HTTPErrors.InternalServerError() module.exports.NotImplemented = new HTTPErrors.NotImplemented() module.exports.BadGateway = new HTTPErrors.BadGateway() module.exports.ServiceUnavailable = new HTTPErrors.ServiceUnavailable() module.exports.GatewayTimeout = new HTTPErrors.GatewayTimeout() module.exports.HTTPVersionNotSupported = new HTTPErrors.HTTPVersionNotSupported() module.exports.VariantAlsoNegotiates = new HTTPErrors.VariantAlsoNegotiates() module.exports.InsufficientStorage = new HTTPErrors.InsufficientStorage() module.exports.LoopDetected = new HTTPErrors.LoopDetected()
1
0
7
+ 41 other calls in file
173 174 175 176 177 178 179 180 181 182
case 503: { httpError = createError.ServiceUnavailable(); break; } case 504: { httpError = createError.GatewayTimeout(); break; } case 505: { httpError = createError.HTTPVersionNotSupported();
0
0
2
+ 41 other calls in file
http-errors.NotFound is the most popular function in http-errors (1819 examples)