prodypanda / MarkEnti

Throwing literals as exceptions is not recommended JS-0091
Anti-pattern
Minor
3 occurrences in this check
Expected an error object to be thrown
 68    await product.save()
 69    return cart
 70  } catch (error) {
 71    throw { 72      message: `Error adding item to cart: ${error.message}`, 73      statusCode: error.statusCode, 74    } 75  }
 76}
 77
Expected an error object to be thrown
 40      }
 41    }
 42    if (product.inventoryCount < quantity) {
 43      throw { 44        message: 45          'Not enough inventory for the product, please reduce quantity or choose a different product.', 46        statusCode: 409, 47      } 48    }
 49
 50    let cart = await Cart.findOne({ user: userId })
Expected an error object to be thrown
 34    // const product = await Product.findOne({ _id: productId })
 35    const product = await Product.findById(productId)
 36    if (!product) {
 37      throw { 38        message: 'Product not found', 39        statusCode: 404, 40      } 41    }
 42    if (product.inventoryCount < quantity) {
 43      throw {