Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
add hint text
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerLeonhardt committed Jan 22, 2018
1 parent 876245b commit a9c0c29
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions common.js
Expand Up @@ -73,6 +73,10 @@ function inputError(message) {
printErrorAndExit(message, 'Input Error:');
}

function printErrorWithHintAndExit(message, hint, prefix) {
printErrorAndExit(message + '\n\n{bold}{yellow}Hint:{/yellow}{/bold} ' + hint, prefix);
}

function printErrorAndExit(message, prefix) {
if (!prefix) {
prefix = 'Error:';
Expand Down Expand Up @@ -217,6 +221,7 @@ module.exports = {
inputError: inputError,
serviceError: serviceError,
printSuccess: printSuccess,
printErrorWithHintAndExit: printErrorWithHintAndExit,
printErrorAndExit: printErrorAndExit,
printDevice: printDevice,
createDeviceJSONObject: createDeviceJSONObject,
Expand Down
5 changes: 5 additions & 0 deletions error-hints.js
@@ -0,0 +1,5 @@
"use strict";

module.exports = {
amqpLinkStolen: 'This issue can occur if you have two services listening in the same consumer group. Specify a different consumer group with the `-c` flag.\nEx. `iothub-explorer monitor-events --login "<connstr>" -c testGroup`\nMore info on consumer groups: https://aka.ms/Mf8kgi'
};
5 changes: 5 additions & 0 deletions iothub-explorer-monitor-events.js
Expand Up @@ -14,6 +14,8 @@ var Promise = require('bluebird');
// local dependencies
var inputError = require('./common.js').inputError;
var serviceError = require('./common.js').serviceError;
var printErrorWithHintAndExit = require('./common.js').printErrorWithHintAndExit;
var errorHints = require('./error-hints.js');

// Azure Event Hubs dependencies
var EventHubsClient = require('azure-event-hubs').Client;
Expand Down Expand Up @@ -73,6 +75,9 @@ var monitorEvents = function () {
return ehClient.createReceiver(consumerGroup, partitionId, { 'startAfterTime': startTime })
.then(function (receiver) {
receiver.on('errorReceived', function (error) {
if (error.transport && error.transport.condition.indexOf('amqp:link:stolen') >= 0) {
printErrorWithHintAndExit(error.message, errorHints.amqpLinkStolen);
}
serviceError(error.message);
});
receiver.on('message', function (eventData) {
Expand Down

0 comments on commit a9c0c29

Please sign in to comment.