How to use the @ember-data/adapter/error function in @ember-data/adapter

To help you get started, we’ve selected a few @ember-data/adapter 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 hashicorp / vault / ui / app / routes / vault / cluster / access / identity / aliases / show.js View on Github external
model(params) {
    let { section } = params;
    let itemType = this.modelFor('vault.cluster.access.identity') + '-alias';
    let tabs = TABS[itemType];
    let modelType = `identity/${itemType}`;
    if (!tabs.includes(section)) {
      const error = new AdapterError();
      set(error, 'httpStatus', 404);
      throw error;
    }
    // TODO peekRecord here to see if we have the record already
    return hash({
      model: this.store.findRecord(modelType, params.item_alias_id),
      section,
    });
  },
github hashicorp / vault / ui / app / routes / vault / cluster / access / identity / show.js View on Github external
model(params) {
    let { section } = params;
    let itemType = this.modelFor('vault.cluster.access.identity');
    let tabs = TABS[itemType];
    let modelType = `identity/${itemType}`;
    if (!tabs.includes(section)) {
      const error = new AdapterError();
      set(error, 'httpStatus', 404);
      throw error;
    }

    // if the record is in the store use that
    let model = this.store.peekRecord(modelType, params.item_id);

    // if we don't have creationTime, we only have a partial model so reload
    if (model && !model.get('creationTime')) {
      model = model.reload();
    }

    // if there's no model, we need to fetch it
    if (!model) {
      model = this.store.findRecord(modelType, params.item_id);
    }
github hashicorp / vault / ui / app / routes / vault / cluster / access / identity.js View on Github external
model(params) {
    let model = MODEL_FROM_PARAM[params.item_type];
    if (!model) {
      const error = new AdapterError();
      set(error, 'httpStatus', 404);
      throw error;
    }
    return model;
  },
});
github hashicorp / vault / ui / app / routes / vault / cluster / access / method / section.js View on Github external
model(params) {
    const { section_name: section } = params;
    if (section !== 'configuration') {
      const error = new AdapterError();
      set(error, 'httpStatus', 404);
      throw error;
    }
    let backend = this.modelFor('vault.cluster.access.method');
    this.wizard.transitionFeatureMachine(this.wizard.featureState, 'DETAILS', backend.type);
    return backend;
  },
github hashicorp / vault / ui / app / routes / vault / cluster / access / method.js View on Github external
return this.store.findAll('auth-method').then(modelArray => {
      const model = modelArray.findBy('id', path);
      if (!model) {
        const error = new AdapterError();
        set(error, 'httpStatus', 404);
        throw error;
      }
      return this.pathHelp.getPaths(model.apiPath, path).then(paths => {
        model.set('paths', paths);
        return model;
      });
    });
  },
github emberjs / data / packages / adapter / addon / rest.js View on Github external
switch (status) {
      case 401:
        return new UnauthorizedError(errors, detailedMessage);
      case 403:
        return new ForbiddenError(errors, detailedMessage);
      case 404:
        return new NotFoundError(errors, detailedMessage);
      case 409:
        return new ConflictError(errors, detailedMessage);
      default:
        if (status >= 500) {
          return new ServerError(errors, detailedMessage);
        }
    }

    return new AdapterError(errors, detailedMessage);
  },
github hashicorp / consul / ui-v2 / app / adapters / http.js View on Github external
error = new NotFoundError(errors, detailedMessage);
          break;
        case 408:
          error = new TimeoutError();
          break;
        case 409:
          error = new ConflictError(errors, detailedMessage);
          break;
        case 422:
          error = new InvalidError(errors); //payload.errors
          break;
        default:
          if (err.statusCode >= 500) {
            error = new ServerError(errors, detailedMessage);
          } else {
            error = new AdapterError(errors, detailedMessage);
          }
      }
    } catch (e) {
      error = e;
    }
    throw error;
  },
  query: function(store, type, query) {
github hashicorp / vault / ui / app / adapters / pki-config.js View on Github external
fetchSection(backendPath, section) {
    const sections = ['cert', 'urls', 'crl', 'tidy'];
    if (!section || !sections.includes(section)) {
      const error = new AdapterError();
      set(error, 'httpStatus', 404);
      throw error;
    }
    return this[`fetch${capitalize(section)}`](backendPath);
  },
github hashicorp / vault / ui / app / routes / vault / cluster / settings / configure-secret-backend / section.js View on Github external
model(params) {
    const { section_name: sectionName } = params;
    const backendModel = this.modelFor('vault.cluster.settings.configure-secret-backend');
    const sections = SECTIONS_FOR_TYPE[backendModel.get('type')];
    const hasSection = sections.includes(sectionName);
    if (!backendModel || !hasSection) {
      const error = new AdapterError();
      set(error, 'httpStatus', 404);
      throw error;
    }
    return this.fetchModel();
  },
github hashicorp / vault / ui / app / routes / vault / cluster / settings / configure-secret-backend.js View on Github external
return this.store.query('secret-engine', { path: backend }).then(modelList => {
      let model = modelList && modelList.get('firstObject');
      if (!model || !CONFIGURABLE_BACKEND_TYPES.includes(model.get('type'))) {
        const error = new AdapterError();
        set(error, 'httpStatus', 404);
        throw error;
      }
      return this.store.findRecord('secret-engine', backend).then(
        () => {
          return model;
        },
        () => {
          return model;
        }
      );
    });
  },