How to use the NotImplemented function from http-errors

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

138
139
140
141
142
143
144
145
146
147
  error.explicitInternalServerError = true
  return error
},

notImplemented: function notImplemented (message) {
  return new createError.NotImplemented(message)
},

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

+ 55 other calls in file

285
286
287
288
289
290
291
292
293
294
295
        tlsHost: apiServerIngressHost,
        ingressAnnotations
      })
    }
    default:
      throw new NotImplemented(`bootstrapping garden terminal host cluster for refType ${refType} not yet implemented`)
  }
}


async function ensureTrustedCertForSeedApiServer (client, seed) {
fork icon89
star icon200
watch icon0

258
259
260
261
262
263
264
265
266
267
if (options.throw) {
  let notImplementedThrowable;
  if (typeof options.notImplemented === 'function') {
    notImplementedThrowable = options.notImplemented(); // set whatever the user returns from their function
  } else {
    notImplementedThrowable = new HttpError.NotImplemented();
  }
  throw notImplementedThrowable;
} else {
  ctx.status = 501;
fork icon9
star icon49
watch icon0

85
86
87
88
89
90
91
92
93
94
if (!user) throw new createErrors.NotAcceptable('Verification code is not valid')

const id = user.id
const result = await knex('users').where('id', id).update('verification_code', '').returning('name')

if (!result) throw new createErrors.NotImplemented('Verification failed')

await sendMail(
  user.email,
  'Account verified',
fork icon4
star icon2
watch icon0

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

+ 41 other calls in file

375
376
377
378
379
380
381
382
383
384
if (!~implemented.indexOf(ctx.method)) {
  if (options.throw) {
    const notImplementedThrowable =
      typeof options.notImplemented === "function"
        ? options.notImplemented() // set whatever the user returns from their function
        : new HttpError.NotImplemented();

    throw notImplementedThrowable;
  } else {
    // 如果不允许包错的话 会返回状态501
fork icon0
star icon2
watch icon0

86
87
88
89
90
91
92
93
94
95
if (!passwordResult) {
  throw createError.Conflict("User credential is not correct");
} else {
  const token = await generateToken(user);
  if (!token) {
    throw createError.NotImplemented("Invalid token! please try again");
  } else {
    return res.status(201).json({
      msg: "Login successfull",
      user: user,
fork icon0
star icon1
watch icon0

59
60
61
62
63
64
65
66
67
68
  ]

  result = await postUserModels(false, queryValueDatabase, queryAdditionalDatabase)
}

if (!result) throw new createErrors.NotImplemented('Registration failed!')

await sendMail(
  data.email,
  'Verify your account',
fork icon0
star icon0
watch icon0

+ 11 other calls in file

98
99
100
101
102
103
104
105
106
107
    template: true,
  },
});

if (!result)
  throw new createErrors.NotImplemented(
    "Request verification code failed"
  );

switch (data.type) {
fork icon0
star icon0
watch icon0

+ 5 other calls in file

580
581
582
583
584
585
586
587
588
589
api.register({
  notFound: () => {
    throw new createHTTPError.NotFound('no such function');
  },
  notImplemented: () => {
    throw new createHTTPError.NotImplemented('function not implemented');
  },
});

// register operation handlers
fork icon0
star icon0
watch icon0

356
357
358
359
360
361
362
363
364
365

const allowedArr = Object.keys(allowed);

if (!~implemented.indexOf(ctx.method)) {
    if (options.throw) {
        throw typeof options.notImplemented === "function" ? options.notImplemented() : new HttpError.NotImplemented();
    } else {
        ctx.status = 501;
        ctx.set("Allow", allowedArr.join(", "));
    }
fork icon0
star icon0
watch icon0

6
7
8
9
10
11
12
13
14
15
  ...req.body,
  dbLangCode: langCode,
  countryId: countryId,
});
if (!state) {
  throw new NotImplemented("state doesn`t created");
}

const updateCountry = await Country.updateOne(
  { _id: countryId },
fork icon0
star icon0
watch icon0

161
162
163
164
165
166
167
168
169
170
case 451: {
  httpError = createError.UnavailableForLegalReasons();
  break;
}
case 501: {
  httpError = createError.NotImplemented();
  break;
}
case 502: {
  httpError = createError.BadGateway();
fork icon0
star icon0
watch icon2

+ 41 other calls in file