How to use the BadGateway function from http-errors

Find comprehensive JavaScript http-errors.BadGateway code examples handpicked from public code repositorys.

209
210
211
212
213
214
215
216
217
218
    `proto=${socket.encrypted ? 'https' : 'http'}`,
    `host=${printIp(authority || host || '')}`
  ].join(';'))
} else if (forwarded) {
  // The forwarded header should not be included in response.
  throw new createError.BadGateway()
}

if (proxyName) {
  if (via) {
fork icon354
star icon0
watch icon1

142
143
144
145
146
147
148
149
150
151
notImplemented: function notImplemented (message) {
  return new createError.NotImplemented(message)
},

badGateway: function badGateway (message) {
  return new createError.BadGateway(message)
},

serviceUnavailable: function serviceUnavailable (message) {
  return new createError.ServiceUnavailable(message)
fork icon30
star icon340
watch icon17

+ 55 other calls in file

13
14
15
16
17
18
19
20
21

transporter.sendMail(transporterOptions, (err, info) => {
  if (err) {
    if (NODE_ENV === 'development') console.log(`Transporter error: ${err}`)

    reject(new createErrors.BadGateway(err.message || 'Email not sent'))
  }

  if (NODE_ENV === 'development') console.log(`Transporter success: ${JSON.stringify(info)}`)
fork icon4
star icon2
watch icon1

180
181
182
183
184
185
186
187
188
versions.setVersion(pVersion, pkg.integrity);

try {
    await this._writeVersions(incoming, versions);
} catch (error) {
    const e = new HttpError.BadGateway();
    end({ labels: { success: false, status: e.status, type } });
    throw e;
}
fork icon2
star icon1
watch icon1

171
172
173
174
175
176
177
178
179
180
module.exports.TooManyRequests = new HTTPErrors.TooManyRequests()
module.exports.RequestHeaderFieldsTooLarge = new HTTPErrors.RequestHeaderFieldsTooLarge()
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()
fork icon1
star icon0
watch icon7

+ 41 other calls in file

165
166
167
168
169
170
171
172
173
174
case 501: {
  httpError = createError.NotImplemented();
  break;
}
case 502: {
  httpError = createError.BadGateway();
  break;
}
case 503: {
  httpError = createError.ServiceUnavailable();
fork icon0
star icon0
watch icon2

+ 41 other calls in file