How to use the boom.internal function in boom

To help you get started, we’ve selected a few boom 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 elastic / kibana / x-pack / plugins / code / server / lsp / workspace_handler.ts View on Github external
}
    let workspaceRepo: Repository;
    if (await this.workspaceExists(repositoryUri, revision)) {
      workspaceRepo = await this.updateWorkspace(repositoryUri, revision, targetCommit);
    } else {
      workspaceRepo = await this.cloneWorkspace(bareRepo, repositoryUri, revision);
    }

    const workspaceHeadCommit = await workspaceRepo.getHeadCommit();
    if (workspaceHeadCommit.sha() !== targetCommit.sha()) {
      const commit = await workspaceRepo.getCommit(targetCommit.sha());
      this.log.info(`checkout ${workspaceRepo.workdir()} to commit ${targetCommit.sha()}`);
      // @ts-ignore
      const result = await Reset.reset(workspaceRepo, commit, Reset.TYPE.HARD, {});
      if (result !== undefined && result !== GitError.CODE.OK) {
        throw Boom.internal(`checkout workspace to commit ${targetCommit.sha()} failed.`);
      }
    }
    this.setWorkspaceRevision(workspaceRepo, workspaceHeadCommit);
    return { workspaceRepo, workspaceRevision: workspaceHeadCommit.sha().substring(0, 7) };
  }
github piobyte / flamingo / src / util / error-reply.js View on Github external
module.exports = function (error/*: Error */, operation/*: function */) {
  const isClientError =
    error instanceof InvalidInputError ||
    error instanceof ProcessingError ||
    typeof error === 'string';

  const message = (operation.config && operation.config.DEBUG) ? error.message : undefined;

  return isClientError ? boom.badRequest(message) : /* istanbul ignore next: can't produce an flamingo src error */ boom.internal(message);
};
github outmoded / oz / lib / ticket.js View on Github external
exports.rsvp = function (app, grant, encryptionPassword, options) {

    options = options || {};

    if (!app || !app.id) {
        throw Boom.internal('Invalid application object');
    }

    if (!grant || !grant.id) {
        throw Boom.internal('Invalid grant object');
    }

    if (!encryptionPassword) {
        throw Boom.internal('Invalid encryption password');
    }

    options.ttl = options.ttl || internals.defaults.rsvpTTL;

    // Construct envelope

    const envelope = {
        app: app.id,
github outmoded / penseur / lib / unique.js View on Github external
return false;
        });

        return taken.length ? taken : (unset ? [] : undefined);
    }

    if (Special.isSpecial(ref)) {
        if (ref.type === 'unset') {
            return [];
        }

        if (ref.type === 'append') {
            if (Array.isArray(ref.value) &&
                ref.flags.single) {

                throw Boom.internal('Cannot add an array as single value to unique index value');
            }

            const result = Array.isArray(ref.value) ? ref.value : [ref.value];
            result._bypass = true;
            return result;
        }

        throw Boom.internal('Cannot increment unique index value');    // type: increment
    }

    return [ref];
};
github novomatic-tech / keycloak-kibana / kibana / plugins / keycloak-kibana / server / services / PermissionService.js View on Github external
async _revokePermission(documentId, permission, script, userIds = null) {
    const updateParams = this._getPermissionUpdateScriptParams({ documentId, permission, userIds, script });
    try {
      await this._cluster.callWithInternalUser('update', updateParams);
    } catch (e) {
      console.warn(e);
      const reason = _.get(e, 'body.error.caused_by.caused_by.reason');
      if (reason === 'conflict') {
        throw Boom.conflict(`Cannot revoke permission for a single user when all users can ${permission} the resource.`);
      } else if (reason === 'forbidden') {
        throw Boom.forbidden('The user is not authorized to remove the permissions for the resource.');
      } else if (reason === 'own_removal') {
        throw Boom.badRequest('Permissions for the creator of the resource can\'t be revoked.');
      }
      throw Boom.internal('Failed to alter permissions for the resource.', e.body.error);
    }
  }
github perborgen / data_hub / node_modules / hapi / lib / payload.js View on Github external
req.on('close', function () {

        return finish(Boom.internal('Request closed before finished reading'));
    });
github sinfo / cannon-api / server / resources / endpoint.js View on Github external
Endpoint.findOne(filter, (err, endpoint) => {
    if (err) {
      log.error({err: err, company: companyId, edition: editionId }, 'error getting endpoint')
      return cb(Boom.internal('error getting endpoint'))
    }
    if (!endpoint) {
      log.error({err: 'not found', company: companyId, edition: editionId }, 'error getting endpoint')
      return cb(Boom.notFound('endpoint not found'))
    }

    cb(null, endpoint.toObject({ getters: true }))
  })
}
github sinfo / cannon-api / server / resources / achievement.js View on Github external
}, changes, (err, achievement) => {
    if (err) {
      log.error({err: err, sessionId: sessionId}, 'error adding user to achievement')
      return cb(Boom.internal())
    }
    
    if (achievement === null) {
      log.error({sessionId: sessionId}, 'error trying to add multiple users to not valid achievement in session')
      return cb(new Error('error trying to add multiple users to not valid achievement in session'), null)
    }

    cb(null, achievement.toObject({ getters: true }))
  })
}
github perborgen / data_hub / node_modules / hapi / lib / auth / hawk.js View on Github external
internals.Scheme.prototype.responseHeader = function (request, response, callback) {

    var options = {
        contentType: response._headers['Content-Type']
    };

    if (response._payload &&
        response._payload.length) {

        options.payload = response._payload.join('');

        var header = Hawk.server.header(request.auth.credentials, request.auth.artifacts, options);
        if (!header) {
            return callback(Boom.internal('Failed generating Hawk response authorization header'));
        }

        response.header('Server-Authorization', header);
        return callback();
    }

    if (response.variety === 'stream') {

        response.header('Trailer', 'Server-Authorization');

        var payload = '';
        response.stream.on('data', function (chunk) {

            payload += chunk;
        });
github sinfo / cannon-api / server / resources / survey.js View on Github external
fs.readFile(path.join(__dirname, '/../helpers/surveyEmail.html'), 'utf8', (err, surveyTemplateSource) => {
    if (err) {
      log.error({ err }, 'Error reading email template. Mail not sent')
      return cb(Boom.internal())
    }

    const surveyTemplate = Handlebars.compile(surveyTemplateSource)
    const context = {url: config.url, session: session}
    const surveyHtml = surveyTemplate(context)
    data.html = surveyHtml

    mailgun.messages().send(data, (err, body) => {
      if (err) {
        log.error({ err }, 'error sending email')
        return cb(err)
      }
      log.info(body, 'emails sent')
      cb(body)
    })
  })