Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

321
Views
how to stop execute process code javascript after catch error?

i have this code

try {
  payload.$set.form = form.map(el => {
    let listType = ['dropdown', 'single-line', 'single-line-number', 'text', 'file'];
    let checkType = listType.includes(el.type)
    let requiredIsBool = typeof el.required == 'boolean'
    let defultIsBool = typeof el.default == 'boolean'
    let orderIsNumber = typeof el.order == 'number'

    if (!el.field_name || el.required == undefined || el.required == null || !el.order || !el.type || el.default == undefined || el.default == null || !requiredIsBool || !checkType || !orderIsNumber || !defultIsBool) {
      return this.sendInvalidResp(this.HTTP_ERROR_MESSAGES.INVALID_VALUE)
    };

    el._id = el._id || formBuilder.ObjectId()
  
    return el
  });

  let result = await formBuilder.updateForm(form_id, payload);

  return this.sendSuccessResp({ status: true, results: result });
} catch (err) {
  return this.sendErrorResp(this.HTTP_ERROR_MESSAGES.INTERNAL_ERROR);
}

This code uses try catch, actually the return error regarding invalid value has been caught. but the code process still continues until update function

how do i fix that? so that the code process stops after getting the caught error

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!