How to use the @hapi/boom.badGateway function in @hapi/boom

To help you get started, we’ve selected a few @hapi/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 opporty-com / Plasma-Cash / plasma-core / src / api / helpers / index.js View on Github external
async function failActionResponse(request, h, err) {
  if (process.env.NODE_ENV === 'production') {
    // In prod, log a limited error message and throw the default Bad Request error.
    console.error('ValidationError:', err.message);
    throw Boom.badGateway(`Invalid response data`);
  }
  // During development, log and respond with the full error.
  console.error('ResponseError:', err);
  const error = Boom.badGateway(`Invalid response data`);
  error.reformat();

  error.output.payload.details = err.details;
  throw error;

}
github opporty-com / Plasma-Cash / plasma-core / src / api / helpers / index.js View on Github external
async function failActionResponse(request, h, err) {
  if (process.env.NODE_ENV === 'production') {
    // In prod, log a limited error message and throw the default Bad Request error.
    console.error('ValidationError:', err.message);
    throw Boom.badGateway(`Invalid response data`);
  }
  // During development, log and respond with the full error.
  console.error('ResponseError:', err);
  const error = Boom.badGateway(`Invalid response data`);
  error.reformat();

  error.output.payload.details = err.details;
  throw error;

}
github opporty-com / Plasma-Cash / plasma-core / src / api / controllers / Token.js View on Github external
async function getByAddress( request, h ) {
  const { address } = request.params;

  let result
  try {
    result = await promiseFromEvent({ action: "getTokenByAddress", payload: address });
  } catch (e) {
    Boom.badGateway( e )
  }

  return result
}
github opporty-com / Plasma-Cash / plasma-core / src / api / controllers / Transaction.js View on Github external
async function getPool(request, h) {
  let result;
  try {
    let data = await plasma({action: "getPool", payload: {}});
    result = data.transactions.map(tx => Transaction.getJson(tx));
  } catch (e) {
    return Boom.badGateway(e)
  }

  return result;
}
github opporty-com / Plasma-Cash / plasma-core / src / api / controllers / Block.js View on Github external
async function proof(request, h) {
  const {tokenId, blockNumber} = request.query;

  let result;
  try {
    let data = await plasma({action: "getProof", payload: {tokenId, blockNumber}});
    result = {hash: ethUtil.addHexPrefix(data.hash.toString('hex'))};
  } catch (e) {
    return Boom.badGateway(e)
  }

  return result
}
github opporty-com / Plasma-Cash / plasma-core / src / api / controllers / Token.js View on Github external
async function getLastTransaction( request, h ) {
  const { tokenId } = request.params;

  let result
  try {
    result = await promiseFromEvent({ action: "getLastTransactionByTokenId", payload: tokenId });
  } catch (e) {
    Boom.badGateway( e )
  }

  return result
}
github hapijs / wreck / lib / index.js View on Github external
internals.tryParseBuffer = function (buffer, next) {

    if (buffer.length === 0) {
        return next(null, null);
    }

    let payload;
    try {
        payload = Bourne.parse(buffer.toString());
    }
    catch (err) {
        return next(Boom.badGateway(err.message, { payload: buffer }));
    }

    return next(null, payload);
};
github opporty-com / Plasma-Cash / plasma-core / src / api / controllers / Block.js View on Github external
async function last(request, h) {
  let result;
  try {
    let block = await plasma({action: "getLastBlock", payload: {}});
    result = Block.getJson(block)
  } catch (e) {
    return Boom.badGateway(e)
  }

  return result
}
github opporty-com / Plasma-Cash / plasma-core / src / api / controllers / Token.js View on Github external
async function get( request, h ) {
  const { tokenId } = request.params;

  let result
  try {
    result = await promiseFromEvent({ action: "getToken", payload: tokenId });
  } catch (e) {
    Boom.badGateway( e )
  }

  return result
}
github opporty-com / Plasma-Cash / plasma-core / src / api / controllers / Validator.js View on Github external
async function getCandidates(request, h) {
  let result;
  try {
    result = await plasma({action: "getCandidates", payload: {}});
  } catch (e) {
    return Boom.badGateway(e)
  }
  return result;
}