How to use the @feathersjs/errors.NotFound function in @feathersjs/errors

To help you get started, we’ve selected a few @feathersjs/errors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Human-Connection / Embed-API / src / services / embeds / embeds.class.js View on Github external
]
    });
    if (embed) {
      return embed.metadata;
    }

    // 2. if not or not older then x minutes, get fresh data and save it to the database
    let metadata = await getMetadata(url, Provider);
    try {
      metadata = Provider.enrichMetadata(metadata);
    } catch (err) {
      // console.error(err);
    }

    if (!metadata.title && !metadata.site_name) {
      throw new errors.NotFound('no data found for url');
    }

    try {
      await this.embeds.create({
        url,
        metadata
      });
    } catch (err) {
      // console.error(err);
    }

    // 3. return cached or fresh metadata
    return metadata;
  }
github feathersjs-ecosystem / feathers-objection / src / error-handler.js View on Github external
case 1:
      case 8:
      case 18:
      case 19:
      case 20:
        feathersError = new errors.BadRequest(error);
        break;
      case 2:
        feathersError = new errors.Unavailable(error);
        break;
      case 3:
      case 23:
        feathersError = new errors.Forbidden(error);
        break;
      case 12:
        feathersError = new errors.NotFound(error);
        break;
      default:
        feathersError = new errors.GeneralError(error);
        break;
    }

    throw feathersError;
  }

  // Objection validation error
  if (error.statusCode) {
    switch (error.statusCode) {
      case 400:
        feathersError = new errors.BadRequest(error);
        break;
github feathersjs-ecosystem / feathers-hooks-common / lib / services / soft-delete-2.js View on Github external
async function getActiveRecord (options, context) {
  const record = await (options.probeCall || defaultProbeCall)(context, options);

  if (record[options.deletedAt || defaultDeletedAt] > -1) {
    throw new errors.NotFound(deletedMessage, { id: context.id });
  }

  return record;
}
github ijjk / mykb / src / services / docs / docs.class.js View on Github external
async get(id, params) {
    const doc = this.docs[id]
    if (!doc) throw new errors.NotFound(`No record found for id '${id}'`)
    if (!doc.md) doc.md = await this.getMd(id)
    return this.docs[id]
  }
github feathersjs-ecosystem / feathers-objection / src / error-handler.js View on Github external
break;

      case 401:
        feathersError = new errors.NotAuthenticated(error);
        break;

      case 402:
        feathersError = new errors.PaymentError(error);
        break;

      case 403:
        feathersError = new errors.Forbidden(error);
        break;

      case 404:
        feathersError = new errors.NotFound(error);
        break;

      case 405:
        feathersError = new errors.MethodNotAllowed(error);
        break;

      case 406:
        feathersError = new errors.NotAcceptable(error);
        break;

      case 408:
        feathersError = new errors.Timeout(error);
        break;

      case 409:
        feathersError = new errors.Conflict(error);
github feathersjs-ecosystem / feathers-memory / lib / index.js View on Github external
async _get (id, params = {}) {
    if (id in this.store) {
      const { query } = this.filterQuery(params);
      const value = this.store[id];

      if (this.options.matcher(query)(value)) {
        return _select(value, params, this.id);
      }
    }

    throw new errors.NotFound(`No record found for id '${id}'`);
  }
github feathersjs / feathers / packages / express / lib / not-found-handler.js View on Github external
return function (req, res, next) {
    const { url } = req;
    const message = `Page not found${verbose ? ': ' + url : ''}`;
    next(new errors.NotFound(message, { url }));
  };
};
github feathersjs-ecosystem / feathers-sequelize / lib / utils.js View on Github external
case 'SequelizeValidationError':
      case 'SequelizeUniqueConstraintError':
      case 'SequelizeExclusionConstraintError':
      case 'SequelizeForeignKeyConstraintError':
      case 'SequelizeInvalidConnectionError':
        throw wrap(new errors.BadRequest(message, { errors: error.errors }), error);
      case 'SequelizeTimeoutError':
      case 'SequelizeConnectionTimedOutError':
        throw wrap(new errors.Timeout(message), error);
      case 'SequelizeConnectionRefusedError':
      case 'SequelizeAccessDeniedError':
        throw wrap(new errors.Forbidden(message), error);
      case 'SequelizeHostNotReachableError':
        throw wrap(new errors.Unavailable(message), error);
      case 'SequelizeHostNotFoundError':
        throw wrap(new errors.NotFound(message), error);
      default:
        throw wrap(new errors.GeneralError(message), error);
    }
  }

  throw error;
};