Variable httpErrorsConst

httpErrors: Record<number, HttpError> = ...

Collection of standard HTTP error codes and their descriptions.

export const httpErrors = {
200: { id: "200", label: "OK", code: 200 },
201: { id: "201", label: "Créé", code: 201 },
204: { id: "204", label: "Aucun contenu", code: 204 },
400: { id: "400", label: "Requête incorrecte", code: 400 },
401: { id: "401", label: "Non autorisé", code: 401 },
403: { id: "403", label: "Interdit", code: 403 },
404: { id: "404", label: "Introuvable", code: 404 },
406: { id: "406" /*label: "Introuvable"*/ }, // pas de label pour la 406 qui sert à renvoyer un message au client
500: { id: "500", label: "Erreur interne du serveur", code: 500 },
502: { id: "502", label: "Mauvaise passerelle", code: 502 },
503: { id: "503", label: "Service indisponible", code: 503 },
};
throw new Meteor.Error(httpErrors["406"].id, `Item not found in collection`);
// Accessing an HTTP error
console.log(httpErrors[404].label); // "Introuvable"
// Checking if a code exists
if (httpErrors[500]) {
console.log("Internal Server Error");
}