u
This commit is contained in:
@@ -34,6 +34,14 @@ function categoryErrorStatus(error) {
|
||||
if (error.message === 'Image not found') return 404;
|
||||
if (error.message === 'Invalid category order') return 400;
|
||||
if (error.message === 'Invalid parent') return 400;
|
||||
if (
|
||||
error.message === 'Category has articles' ||
|
||||
error.message === 'Category has subcategories' ||
|
||||
error.message === 'Category is assigned to POS terminals' ||
|
||||
error.message?.includes('FOREIGN KEY constraint failed') ||
|
||||
error.message?.includes('foreign key constraint') ||
|
||||
error.message?.includes('REFERENCE constraint')
|
||||
) return 409;
|
||||
return 500;
|
||||
}
|
||||
|
||||
@@ -519,6 +527,18 @@ export function register(app, basePath = '') {
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
* 404:
|
||||
* description: Category not found
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
* 409:
|
||||
* description: Category has articles or subcategories
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
app.delete(`${basePath}/category/:id`, async (req, res) => {
|
||||
const parsed = parsePositiveInt(req.params.id, 'id');
|
||||
|
||||
Reference in New Issue
Block a user