Custom Error throws Uncaught exception in admin browser console

System Information
  • **Strapi Version4.5.5:
  • Operating System:
  • **DatabasePostgreSQL:
  • **Node Version18:
  • NPM Version:
  • Yarn Version:

When i try to throw some custom error for my validation, im get a Uncaught exception error in the brower console See: Screenshot Below

/**
 * 
 * @param strapi // strapi global instance
 * @param ctx // Context
 */
const { ValidationError } = require("@strapi/utils").errors;
export const UpdateInventoryCodes = async (strapi, ctx) =>{
    const { data, where, select, populate } = ctx.params;
    const ctx2 = strapi.requestContext.get();
   
    console.log("ctx2.request.body=====>",ctx2.request.body);

    throw new ValidationError('Duplicate Varient'); // throwing errors will STOP the creation.
}