lykmapipo / sails-hook-validation

Custom validation error messages for sails model with i18n support
104 stars 29 forks source link

Didn't work with async function's try catch #26

Open ablipan opened 8 years ago

ablipan commented 8 years ago
(async function() {
      try {
        // update Store
        if (paramStore.id) {
          const finded = await Store.findOne(paramStore.id);
          _.assign(finded, paramStore);
          finded.save();
        }else {
          // add Store
          await Store.create(paramStore);
        }
        return res.ok();
      } catch (err) {
        sails.log.error(err);
        sails.log.error(err.Errors);
        return res.serverError(err);
      }
    })();

the err.Errors is undefined.

lykmapipo commented 8 years ago

@ablipan sails-hook-validation works only with model static methods only i.e

For instance method consider using sails-model-new

Hope it helps.