Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixing issue with generic error throwing

  • Loading branch information...
commit f35f290942afc6068b0054df8f2b367785483c4e 1 parent 0563191
@andrerod andrerod authored
View
8 lib/services/core/servicebussettings.js
@@ -127,7 +127,11 @@ ServiceBusSettings.createFromConnectionString = function (connectionString) {
try {
return ServiceBusSettings.createFromSettings(tokenizedSettings);
} catch (e) {
- // Replace no match settings exception by no match connection string one.
- ServiceSettings.noMatchConnectionString(connectionString);
+ if (typeof e === 'NoMatchError') {
+ // Replace no match settings exception by no match connection string one.
+ ServiceSettings.noMatchConnectionString(connectionString);
+ } else {
+ throw e; // let others bubble up
+ }
}
};
View
8 lib/services/core/servicemanagementsettings.js
@@ -115,7 +115,11 @@ ServiceManagementSettings.createFromConnectionString = function (connectionStrin
try {
return ServiceManagementSettings.createFromSettings(tokenizedSettings);
} catch (e) {
- // Replace no match settings exception by no match connection string one.
- ServiceSettings.noMatchConnectionString(connectionString);
+ if (typeof e === 'NoMatchError') {
+ // Replace no match settings exception by no match connection string one.
+ ServiceSettings.noMatchConnectionString(connectionString);
+ } else {
+ throw e; // let others bubble up
+ }
}
}
View
7 lib/services/core/servicesettings.js
@@ -20,6 +20,9 @@ var ConnectionStringParser = require('./connectionstringparser');
exports = module.exports;
+function NoMatchError () { }
+NoMatchError.prototype = new Error();
+
/**
* Throws an exception if the connection string format does not match any of the
* available formats.
@@ -29,7 +32,7 @@ exports = module.exports;
* @return none
*/
exports.noMatchConnectionString = function (connectionString) {
- throw new Error('The provided connection string ' + connectionString + ' does not have complete configuration settings.');
+ throw new NoMatchError('The provided connection string ' + connectionString + ' does not have complete configuration settings.');
};
/**
@@ -41,7 +44,7 @@ exports.noMatchConnectionString = function (connectionString) {
* @return none
*/
exports.noMatchSettings = function (settings) {
- throw new Error('The provided settings ' + JSON.stringify(settings) + ' are not complete.');
+ throw new NoMatchError('The provided settings ' + JSON.stringify(settings) + ' are not complete.');
};
/**
View
1  lib/services/core/storageserviceclient.js
@@ -70,6 +70,7 @@ util.inherits(StorageServiceClient, ServiceClient);
*/
StorageServiceClient.getStorageSettings = function (storageAccountOrConnectionString, storageAccessKey, host) {
var storageServiceSettings;
+
if (storageAccountOrConnectionString && !storageAccessKey) {
// If storageAccountOrConnectionString was passed and no accessKey was passed, assume connection string
storageServiceSettings = StorageServiceSettings.createFromConnectionString(storageAccountOrConnectionString);
View
8 lib/services/core/storageservicesettings.js
@@ -277,7 +277,11 @@ StorageServiceSettings.createFromConnectionString = function (connectionString)
try {
return StorageServiceSettings.createFromSettings(tokenizedSettings);
} catch (e) {
- // Replace no match settings exception by no match connection string one.
- ServiceSettings.noMatchConnectionString(connectionString);
+ if (typeof e === 'NoMatchError') {
+ // Replace no match settings exception by no match connection string one.
+ ServiceSettings.noMatchConnectionString(connectionString);
+ } else {
+ throw e; // let others bubble up
+ }
}
};
View
11 test/services/blob/blobservice-tests.js
@@ -58,7 +58,7 @@ suite('blobservice-tests', function () {
teardown(function (done) {
blobtestutil.tearDownTest(numberTests, blobService, testPrefix, done);
});
-/*
+
test('IncorrectContainerNames', function (done) {
assert.throws(function () { blobService.createContainer(null, function () { }); },
BlobService.incorrectContainerNameErr);
@@ -1264,15 +1264,16 @@ suite('blobservice-tests', function () {
});
});
});
-*/
+
test('storageConnectionStrings', function (done) {
- var connectionString = 'DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=mykey';
+ var key = 'AhlzsbLRkjfwObuqff3xrhB2yWJNh1EMptmcmxFJ6fvPTVX3PZXwrG2YtYWf5DPMVgNsteKStM5iBLlknYFVoA==';
+ var connectionString = 'DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=' + key;
var blobService = azure.createBlobService(connectionString);
assert.equal(blobService.storageAccount, 'myaccount');
- assert.equal(blobService.storageAccessKey, 'mykey');
+ assert.equal(blobService.storageAccessKey, key);
assert.equal(blobService.protocol, 'https://');
- assert.equal(blobService.host, 'blob.core.windows.net');
+ assert.equal(blobService.host, 'myaccount.blob.core.windows.net');
done();
});
View
5 test/services/queue/queueservice-tests.js
@@ -452,11 +452,12 @@ suite('queueservice-tests', function () {
});
test('storageConnectionStrings', function (done) {
- var connectionString = 'DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=mykey';
+ var key = 'AhlzsbLRkjfwObuqff3xrhB2yWJNh1EMptmcmxFJ6fvPTVX3PZXwrG2YtYWf5DPMVgNsteKStM5iBLlknYFVoA==';
+ var connectionString = 'DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=' + key;
var queueService = azure.createQueueService(connectionString);
assert.equal(queueService.storageAccount, 'myaccount');
- assert.equal(queueService.storageAccessKey, 'mykey');
+ assert.equal(queueService.storageAccessKey, key);
assert.equal(queueService.protocol, 'https://');
done();
View
5 test/services/table/tableservice-tests.js
@@ -768,11 +768,12 @@ suite('tableservice-tests', function () {
});
test('storageConnectionStrings', function (done) {
- var connectionString = 'DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=mykey';
+ var key = 'AhlzsbLRkjfwObuqff3xrhB2yWJNh1EMptmcmxFJ6fvPTVX3PZXwrG2YtYWf5DPMVgNsteKStM5iBLlknYFVoA==';
+ var connectionString = 'DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=' + key;
var tableService = azure.createTableService(connectionString);
assert.equal(tableService.storageAccount, 'myaccount');
- assert.equal(tableService.storageAccessKey, 'mykey');
+ assert.equal(tableService.storageAccessKey, key);
assert.equal(tableService.protocol, 'https://');
done();
Please sign in to comment.
Something went wrong with that request. Please try again.