Example #1
0
 background.approveTransaction(txData.id, (err) => {
   if (err) {
     dispatch(actions.txError(err))
     return log.error(err.message)
   }
   dispatch(actions.completedTx(txData.id))
 })
Example #2
0
    that.listen = function (eventType, listener, isInternal) {
        if (listener === undefined) {
            return;
        }
        var invalidEventType = typeof eventType !== 'string' || !eventType;
        var invalidListener = typeof listener !== 'function';
        if (invalidEventType || invalidListener) {
            log.error("Invalid request to add event listener to", eventType, listener);
            return;
        }

        eventList[eventType] = eventList[eventType] || [];
        listener.isInternal = !!isInternal; // boolify

        var toString = function (fn) {
            return fn.toString();
        };
        var isNotAlreadyAdded = eventList[eventType].map(toString).indexOf(listener.toString()) === -1;

        if (isNotAlreadyAdded) {
            eventList[eventType].push(listener);
        } else {
            log.warn("Not adding duplicate listener to", eventType, listener);
        }
    };
Example #3
0
function route(data, bot){
  // eventsType: start, message, open, close

  log.debug('**** Routing message \''+ data.type + '\' ****');
  log.trace('**** Routing message data' + util.inspect(data) + '****');

  if (typeof messageHandlerList[data.user] === 'function'){
    messageHandlerList[data.user](data, bot);;
  }else if (typeof messageHandlerList[data.type] === 'function') {
    messageHandlerList[data.type](data, bot);
  }else if ( data.subtype &&
      typeof messageHandlerList[data.type + '_' + data.subtype] === 'function') {
    messageHandlerList[data.type + '_' + data.subtype](data, bot);
  }else{
    log.error('---- Error routing message, handler \''+data.type+'\' with subtype \''+data.subtype+'\' not found! ----');
    log.trace('**** Routing message data' + util.inspect(data) + '****');

    if( log.getlevel() <= log.levels.ERROR){
      bot.postMessageToUser(common.config().error_channel_id,
        'ERROR: Routing message. Handler \''+data.type+'\' with subtype \''+data.subtype+'\' not found!', {as_user:'******'});
    }
    
    if( log.getlevel() <= log.levels.TRACE){
      bot.postMessageToUser(common.config().error_channel_id,
        'Message data: '+util.inspect(data), {as_user:'******'});
    }
  }
}
Example #4
0
 background.setCustomRpc(newRpc, (err, result) => {
   if (err) {
     log.error(err)
     return dispatch(self.displayWarning('Had a problem changing networks!'))
   }
   dispatch(actions.setSelectedToken())
 })
Example #5
0
 function safeAction(item) {
     try {
         action(item);
     } catch (err) {
         log.error("Error calling queue action.", err);
     }
 }
Example #6
0
 db.save('settings', settings, function (err) {
   // emit an event which indicates failure or success
   if (err) {
     log.error('ERROR: Could not save settings.');
     return events.emit('settings:failed', err);
   }
   events.emit('settings:saved');
 });
Example #7
0
                  copyDocFile('Windows10-next-steps.md', platformDir, function (err) {
                    if (err) {
                      log.error('WARNING: Failed to copy documentation file to the Web platform folder.');
                      log.debug(err);
                    }

                    return task.resolve();
                  });
Example #8
0
 background.setProviderType(type, (err, result) => {
   if (err) {
     log.error(err)
     return dispatch(self.displayWarning('Had a problem changing networks!'))
   }
   dispatch(actions.updateProviderType(type))
   dispatch(actions.setSelectedToken())
 })
 next((/** @type {Function} */ cb) => {
   if (res.error) {
     log.error('Error in RPC response:\n', res)
   }
   if (req.isMetamaskInternal) return
   log.info(`RPC (${opts.origin}):`, req, '->', res)
   cb()
 })
Example #10
0
  platformUtils.makeAppx(directory, outputPath, function (err) {
    if (err) {
      log.error('ERROR: ' + err.message);
      return;
    }

    log.info('The app store package was created successfully!');
  });
      .catch(function(err) {
        log.error('template-subscription: Subscription error for ' + channel, err);
        this.trigger('subscriptionError', channel, err);

        if (subscription === this._subscription) {
          this._subscription = null;
        }
      });
Example #12
0
 results.forEach(function (task) {
   if (task.state !== 'fulfilled') {
     log.error('WARNING: ' + task.reason.message);
     if (!err) {
       err = new Error('One or more errors occurred when generating the application.');
     }
   }
 });
Example #13
0
 error: function(jqXHR, textStatus) {
     log.error('Unable to contact the WQP services: ' + textStatus);
     if (jqXHR.status === 401 || jqXHR.status === 403) {
         deferred.reject('No longer authorized to use the application. Please reload the page to login again');
     } else {
         deferred.reject('Unable to contact the WQP services: ' + textStatus);
     }
 }
var fail = function (req, res, code, msg) {
    // log a failure, and finish the HTTP request with an error code
    msg = msg || '';
    log.error('[' + code + ']', req.method, req.url + ':', msg);
    res.writeHead(code);
    res.write(msg);
    res.end();
};
Example #15
0
    this._play = function(name) {
      if (!buffer[name]) {
        Log.error(tag, "no sprite: " + name);
        return;
      }

      buffer[name].play();
    };
Example #16
0
        set: function ( value ) {
            log.debug( "Setting param", name, "value to", value );
            // Sanitize the value with min/max
            // bounds first.
            if ( typeof value !== typeof defaultValue ) {
                log.error( "Attempt to set a", ( typeof defaultValue ), "parameter to a", ( typeof value ), "value" );
                return;
            }
            // Sanitize the value with min/max
            // bounds first.
            if ( typeof value === "number" ) {
                if ( value > maxValue ) {
                    log.debug( this.name, 'clamping to max' );
                    value = maxValue;
                } else if ( value < minValue ) {
                    log.debug( this.name + ' clamping to min' );
                    value = minValue;
                }
            }

            // Store the incoming value for getter
            value_ = value;

            // Map the value
            if ( typeof mappingFunction === 'function' ) {
                // Map if mappingFunction is defined
                value = mappingFunction( value );
            }

            if ( !calledFromAutomation_ ) {
                log.debug( "Clearing Automation for", name );
                window.clearInterval( intervalID_ );
            }
            calledFromAutomation_ = false;

            // Dispatch the value
            if ( typeof setter === 'function' && baseSound.audioContext ) {
                setter( aParams, value, baseSound.audioContext );
            } else if ( aParams ) {
                // else if param is defined, set directly
                if ( aParams instanceof AudioParam ) {
                    var array = [];
                    array.push( aParams );
                    aParams = array;
                }
                aParams.forEach( function ( thisParam ) {
                    if ( baseSound.isPlaying ) {
                        //dezipper if already playing
                        thisParam.setTargetAtTime( value, baseSound.audioContext.currentTime, Config.DEFAULT_SMOOTHING_CONSTANT );
                    } else {
                        //set directly if not playing
                        log.debug( "Setting param", name, 'through setter' );
                        thisParam.setValueAtTime( value, baseSound.audioContext.currentTime );
                    }
                } );
            }
        },
Example #17
0
 socket.on('close', err => {
   handler.logout()
   socket.destroy()
   if(err){
     log.error(socketLog(socket,'socket closed due to error'))
   } else {
     log.debug(socketLog(socket,'socket closed'))
   }
 })
 return function (req, res) {
     try {
         return handler.apply(that, arguments);
     } catch (e) {
         log.error("Error in handler for " +
             req.method + ' ' + req.url + ': ', e
         );
     }
 };
 .catch((reason) => {
   log.error(reason)
   return this.setState({
     loadingEns: false,
     ensResolution: ZERO_ADDRESS,
     ensFailure: true,
     hoverText: reason.message,
   })
 })
Example #20
0
events.on('app:quit', function() {
  log.info('App is quiting, cleanup avatars');
  try {
    rimraf.sync(tempAvatarDirectory);
  }
  catch(err) {
    log.error('Something went wrong while cleaning up the avatars: ' + err.message + err.stack);
  }
});
export function track(event, data) {
  if (window.metrics) {
    try {
      window.metrics.track(event, data);
    } catch (e) {
      log.error(`Metrics library error for event ${event}: ${e}`);
    }
  }
}
Example #22
0
    mkdirp(platformDir, function (err) {
      function createDownloaderImageCallback(downloadTask, icons, size) {
        return function (err, data) {
          if (err) {
            log.warn('WARNING: Failed to download icon file: ' + icons[size] + ' (' + err.message + ')');
            log.debug(err);
          } else {
            var localPath = path.basename(data.path);
            icons[size] = localPath;
          }

          downloadTask.resolve();
        };
      }

      if (err && err.code !== 'EEXIST') {
        log.error(err.message);
        return task.reject(new Error('The Chrome project could not be created successfully.'));
      }

      // download icons to the app's folder
      var pendingDownloads = [];
      log.info('Downloading Chrome icons...');
      var icons = chromeManifestInfo.content.icons;
      for (var size in icons) {
        var downloadTask = new Q.defer();
        pendingDownloads.push(downloadTask.promise);
        var iconUrl = url.resolve(w3cManifestInfo.content.start_url, icons[size]);
        var iconFileName = url.parse(icons[size]).pathname.split('/').pop();
        var iconFilePath = path.join(platformDir, iconFileName);
        downloader.downloadImage(iconUrl, iconFilePath, createDownloaderImageCallback(downloadTask, icons, size));
      }

      // copy the manifest file to the app folder
      Q.allSettled(pendingDownloads)
        .done(function () {
        log.info('Copying the Chrome manifest to the app folder...');
        var manifestFilePath = path.join(platformDir, 'manifest.json');
        manifestTools.writeToFile(chromeManifestInfo, manifestFilePath, function (err) {
          if (err) {
            log.error('ERROR: Failed to copy the manifest to the Chrome platform folder.');
            log.debug(err);
            return task.reject(new Error('The Chrome project could not be created successfully.'));
          }

          copyDocFile('Chrome-next-steps.md', platformDir, function (err) {
            if (err) {
              log.error('WARNING: Failed to copy documentation file to the Chrome platform folder.');
              log.debug(err);
            }

            return task.resolve();
          });
        });
      });
    });
Example #23
0
 /**
  * Error callback for fetching article information
  *
  * @param data
  */
 function getArticleError(returnedData) {
     log.error(config.errors.en.type.api + ': ' + config.api.article + '/' + data.queryParams.articleId);
     log.info(returnedData);
     var errorInfo = utils.formatErrorInformation(returnedData);
     errorInfo.errorType = null;
     errorInfo.ref = 'getArticleError';
     errorInfo.type = config.errors.en.type.api;
     $('#article').empty().html(data.template.errorMessage(errorInfo));
     $('#error-console').empty().html(data.template.errorDetail(errorInfo));
 }
Example #24
0
    release () {
        if (this.retain_count <= 0) {
            log.error(`Texture '${this.name}': releasing texture with retain count of '${this.retain_count}'`);
        }

        this.retain_count--;
        if (this.retain_count <= 0) {
            this.destroy();
        }
    }
Example #25
0
 win.cookies.remove({ url: cookie_url, name: cookie.name }, function (result) {
   if (result) {
     result = result[0];
     log.info('cookie removed:' + result.name);
     resolve(result);
   } else {
     log.error('failed to remove cookie');
     reject(new Error('Failed to delete cookie.'));
   }
 });
Example #26
0
module.exports = function() {
  if (fs.existsSync('experiments')) {
    log.error("Error: already a dimebox experiment set.")
    process.exit(1)
  }

  try {
    const dirs = ['experiments/jobs', 'experiments/results', 'experiments/metadata']
    dirs.forEach(dir => { fse.mkdirp(dir); })

    const exampleFilename = path.resolve(__dirname, '../examples/exp.yml');
    fse.copy(exampleFilename, './experiments/exp.yml')
    log.debug(`Copied ${exampleFilename}`)

    setMetadata()
  } catch (err) {
    log.error("Cannot init", err)
  }
}
Example #27
0
 cancelCall().then((result) => {
   if (result.status == 200) {
     logEvent("Subscription", "Cancel", "Cancelled");
     dispatch(cancelActions.success(result.body));
   } else {
     log.error(result);
     throw new Error("Bad response");
   }
   return;
 }).catch(err => {
Example #28
0
CallManager.prototype.update_call_status = function (details) {
  // NodeJS Twilio clients wraps TwiML responses with different
  // parameter names than XML POSTs. Handle both types of message name.
  var status = details.CallStatus || details.status,
    sid = details.CallSid || details.sid,
    number = details.To || details.to

  // Ensure message sid matches active call sid
  if (!this.is_message_valid(status, sid)) {
    log.error('ERROR: Invalid message received for call (' + this.active_call.sid + '): ' + details)
    return null
  }

  switch (status) {
    // Store new call reference when outbound call is queued.
    case 'queued':
      this.active_call = {sid: sid, status: status, number: number}
      this.emit(status)
      break
    case 'ringing':
    case 'in-progress':
      var old = this.active_call.status
      this.active_call.status = status
      // Don't emit the same event multiple times
      if (old !== status) this.emit(status)
      break
    // When the phone call ends, for any reason, remove
    // the active call reference so we can make another.
    case 'completed':
    case 'busy':
    case 'failed':
    case 'no-answer':
    case 'canceled':
      this.active_call = null
      this.emit(status)
      break
    default:
      status = null
      log.error('ERROR: Unknown call state encountered (' + status + '): ' + details)
  }

  return status
}
Example #29
0
const renderPrefs = async () => {
  try {
    const bgPage = chrome.extension.getBackgroundPage()
    const storeRef = bgPage.storeRef
    const st = storeRef.getValue()
    const parentNode = document.getElementById('prefsContent')
    const modal = (
      <PreferencesModal
        onClose={onClose}
        initialPrefs={st.preferences}
        storeRef={storeRef}
        onSubmit={(prefs) => onUpdatePreferences(storeRef, prefs)} />)
    ReactDOM.render(modal, parentNode)
  } catch (e) {
    log.error('caught exception rendering preferences page:')
    log.error(e.stack)
    throw e
  }
}
Example #30
0
 validationResults.forEach(function (validationResult) {
   var validationMessage = 'Validation ' + validationResult.level + ' (' + validationResult.platform + '): ' + validationResult.description;
   if (validationResult.level === validationConstants.levels.warning) {
     log.warn(validationMessage);
   } else if (validationResult.level === validationConstants.levels.suggestion) {
     log.info(validationMessage);
   } else if (validationResult.level === validationConstants.levels.error) {
     log.error(validationMessage);
   }
 });