Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions packages/error-reporting/src/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ var isObject = is.object;
var isBoolean = is.boolean;
var isString = is.string;
var isNumber = is.number;
var isEmpty = is.empty;
var isNull = is.null;
var version = require('../package.json').version;

/**
Expand Down Expand Up @@ -146,15 +144,6 @@ var Configuration = function(givenConfig, logger) {
* @type {String}
*/
this._version = version;
/**
* Boolean flag indicating whether or not the configuration instance was able
* to find a set of usable credentials to attempt authorization against the
* Stackdriver API.
* @memberof Configuration
* @private
* @type {Boolean}
*/
this._lacksValidCredentials = true;
/**
* The _givenConfiguration property holds a ConfigurationOptions object
* which, if valid, will be merged against by the values taken from the meta-
Expand Down Expand Up @@ -278,29 +267,6 @@ Configuration.prototype._gatherLocalConfiguration = function() {
} else if (has(this._givenConfiguration, 'credentials')) {
throw new Error('config.credentials must be a valid credentials object');
}
this._checkAuthConfiguration();
};
/**
* The _checkAuthConfiguration function is responsible for determining whether
* or not a configuration instance, after having gathered configuration from
* environment and runtime, has credentials information enough to attempt
* authorization with the Stackdriver Errors API.
* @memberof Configuration
* @private
* @function _checkAuthConfiguration
* @returns {Undefined} - does not return anything
*/
Configuration.prototype._checkAuthConfiguration = function() {
if (!isNull(this._key) || !isNull(this._keyFilename) ||
!isNull(this._credentials) ||
!isEmpty(process.env.GOOGLE_APPLICATION_CREDENTIALS)) {
this._lacksValidCredentials = false;
} else {
this._logger.warn([
'Unable to find credential information on instance. This library will',
'be unable to communicate with the Stackdriver API to save errors.'
].join(' '));
}
};
/**
* The _checkLocalProjectId function is responsible for determing whether the
Expand Down Expand Up @@ -408,14 +374,4 @@ Configuration.prototype.getServiceContext = function() {
Configuration.prototype.getVersion = function() {
return this._version;
};
/**
* Returns the _lacksValidCredentials property on the instance.
* @memberof Configuration
* @public
* @function getVersion
* @returns {Boolean} - returns the _lacksValidCredentials property
*/
Configuration.prototype.lacksCredentials = function() {
return this._lacksValidCredentials;
};
module.exports = Configuration;
4 changes: 0 additions & 4 deletions packages/error-reporting/src/interfaces/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ function makeExpressHandler(client, config) {
var ctxService = '';
var ctxVersion = '';

if (config.lacksCredentials()) {
next(err);
}

if (isObject(config)) {
ctxService = config.getServiceContext().service;
ctxVersion = config.getServiceContext().version;
Expand Down
18 changes: 5 additions & 13 deletions packages/error-reporting/src/interfaces/hapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,18 @@ function makeHapiPlugin(client, config) {
if (isObject(server)) {
if (isFunction(server.on)) {
server.on('request-error', function(req, err) {
var em = hapiErrorHandler(req, err, config);

if (!config.lacksCredentials()) {
client.sendError(em);
}
client.sendError(hapiErrorHandler(req, err, config));
});
}

if (isFunction(server.ext)) {
server.ext('onPreResponse', function(request, reply) {
var em = null;

if (isObject(request) && isObject(request.response) &&
request.response.isBoom) {
em = hapiErrorHandler(request, new Error(request.response.message),
config);

if (!config.lacksCredentials()) {
client.sendError(em);
}
var em = hapiErrorHandler(request,
new Error(request.response.message),
config);
client.sendError(em);
}

if (isObject(reply) && isFunction(reply.continue)) {
Expand Down
7 changes: 1 addition & 6 deletions packages/error-reporting/src/interfaces/koa.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,13 @@ function koaErrorHandler(client, config) {
* @returns {Undefined} does not return anything
*/
return function *(next) {
var em;
var svc = config.getServiceContext();

try {

yield next;
} catch (err) {
if (config.lacksCredentials()) {
return;
}

em = new ErrorMessage()
var em = new ErrorMessage()
.consumeRequestInformation(
koaRequestInformationExtractor(this.request, this.response))
.setServiceContext(svc.service,
Expand Down
3 changes: 0 additions & 3 deletions packages/error-reporting/src/interfaces/manual.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ function handlerSetup(client, config) {
*/
function reportManualError(err, request, additionalMessage, callback) {
var em;
if (config.lacksCredentials()) {
return;
}
if (isString(request)) {
// no request given
callback = additionalMessage;
Expand Down
3 changes: 0 additions & 3 deletions packages/error-reporting/src/interfaces/restify.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@ function restifyRequestHandler(client, config, req, res, next) {
function serverErrorHandler(client, config, server) {

server.on('uncaughtException', function(req, res, reqConfig, err) {
if (config.lacksCredentials()) {
return;
}
var em = new ErrorMessage().consumeRequestInformation(
expressRequestInformationExtractor(req, res));

Expand Down