How to use the Gone function from http-errors

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

55
56
57
58
59
60
61
62
63
64
conflict: function conflict (message) {
  return new createError.Conflict(message)
},

gone: function gone (message) {
  return new createError.Gone(message)
},

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

+ 55 other calls in file

74
75
76
77
78
79
80
81
82
83

if (
  differenceInMinutes(new Date(), new Date(createdAt)) >
  options.security.codeLifetime
) {
  throw new Gone()
}

const { rows } = await server.pg.write.query(
  tokenInsert({ id, onsetDate, testType })
fork icon21
star icon0
watch icon0

150
151
152
153
154
155
156
157
158
159
module.exports.MethodNotAllowed = new HTTPErrors.MethodNotAllowed()
module.exports.NotAcceptable = new HTTPErrors.NotAcceptable()
module.exports.ProxyAuthenticationRequired = new HTTPErrors.ProxyAuthenticationRequired()
module.exports.RequestTimeout = new HTTPErrors.RequestTimeout()
module.exports.Conflict = new HTTPErrors.Conflict()
module.exports.Gone = new HTTPErrors.Gone()
module.exports.LengthRequired = new HTTPErrors.LengthRequired()
module.exports.PreconditionFailed = new HTTPErrors.PreconditionFailed()
module.exports.PayloadTooLarge = new HTTPErrors.PayloadTooLarge()
module.exports.URITooLong = new HTTPErrors.URITooLong()
fork icon1
star icon0
watch icon7

+ 41 other calls in file

89
90
91
92
93
94
95
96
97
98
case 409: {
  httpError = createError.Conflict();
  break;
}
case 410: {
  httpError = createError.Gone();
  break;
}
case 411: {
  httpError = createError.LengthRequired();
fork icon0
star icon0
watch icon2

+ 41 other calls in file

20
21
22
23
24
25
26
27
28
29

if (!httpRequest.params.id || !ObjectId.isValid(httpRequest.params.id)) throw new BadRequest('Track Id is empty or invalid!');

const trackId = new ObjectId(httpRequest.params.id);
const track = await this._searcher.searchById(trackId);
if (!track) throw new Gone('Track has been propably deleted and is no longer available.');

const { length: trackFileSizeFromDb } = await this._dbClient.db()
  .collection('tracks.files')
  .findOne({ _id: track.fileId }, { projection: { length: 1 } });
fork icon0
star icon0
watch icon2