Skip to content

Commit

Permalink
gracefully continue if error function is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
alokrajiv committed Oct 11, 2017
1 parent 86386cd commit 11cbc5a
Showing 1 changed file with 108 additions and 0 deletions.
108 changes: 108 additions & 0 deletions www/mainHandle.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ function StorageHandle() {


StorageHandle.prototype.set = function(reference, value, success, error) {

//if error is null then replace with empty function to silence warnings
if(!error){
error = function(){};
}

if (reference === null) {
error("The reference can't be null");
return;
Expand Down Expand Up @@ -91,6 +97,12 @@ StorageHandle.prototype.set = function(reference, value, success, error) {

/* removing */
StorageHandle.prototype.remove = function(reference, success, error) {

//if error is null then replace with empty function to silence warnings
if(!error){
error = function(){};
}

if (reference === null) {
error("Null reference isn't supported");
return;
Expand All @@ -110,6 +122,12 @@ StorageHandle.prototype.remove = function(reference, success, error) {

/* clearing */
StorageHandle.prototype.clear = function(success, error) {

//if error is null then replace with empty function to silence warnings
if(!error){
error = function(){};
}

if (inBrowser) {
try {
localStorage.clear();
Expand All @@ -125,6 +143,12 @@ StorageHandle.prototype.clear = function(success, error) {

/* boolean storage */
StorageHandle.prototype.putBoolean = function(reference, aBoolean, success, error) {

//if error is null then replace with empty function to silence warnings
if(!error){
error = function(){};
}

if (reference === null) {
error("Null reference isn't supported");
return;
Expand Down Expand Up @@ -156,6 +180,12 @@ StorageHandle.prototype.putBoolean = function(reference, aBoolean, success, erro


StorageHandle.prototype.getBoolean = function(reference, success, error) {

//if error is null then replace with empty function to silence warnings
if(!error){
error = function(){};
}

if (reference === null) {
error("Null reference isn't supported");
return;
Expand All @@ -177,6 +207,12 @@ StorageHandle.prototype.getBoolean = function(reference, success, error) {

/* int storage */
StorageHandle.prototype.putInt = function(reference, anInt, success, error) {

//if error is null then replace with empty function to silence warnings
if(!error){
error = function(){};
}

if (reference === null) {
error("Null reference isn't supported");
return;
Expand All @@ -185,6 +221,12 @@ StorageHandle.prototype.putInt = function(reference, anInt, success, error) {
};

StorageHandle.prototype.getInt = function(reference, success, error) {

//if error is null then replace with empty function to silence warnings
if(!error){
error = function(){};
}

if (reference === null) {
error("Null reference isn't supported");
return;
Expand All @@ -195,6 +237,12 @@ StorageHandle.prototype.getInt = function(reference, success, error) {

/* float storage */
StorageHandle.prototype.putDouble = function(reference, aFloat, success, error) {

//if error is null then replace with empty function to silence warnings
if(!error){
error = function(){};
}

if (reference === null) {
error("Null reference isn't supported");
return;
Expand All @@ -203,6 +251,12 @@ StorageHandle.prototype.putDouble = function(reference, aFloat, success, error)
};

StorageHandle.prototype.getDouble = function(reference, success, error) {

//if error is null then replace with empty function to silence warnings
if(!error){
error = function(){};
}

if (reference === null) {
error("Null reference isn't supported");
return;
Expand All @@ -218,6 +272,12 @@ StorageHandle.prototype.getDouble = function(reference, success, error) {

/* string storage */
StorageHandle.prototype.putString = function(reference, s, success, error) {

//if error is null then replace with empty function to silence warnings
if(!error){
error = function(){};
}

if (reference === null) {
error("Null reference isn't supported");
return;
Expand All @@ -226,6 +286,12 @@ StorageHandle.prototype.putString = function(reference, s, success, error) {
};

StorageHandle.prototype.getString = function(reference, success, error) {

//if error is null then replace with empty function to silence warnings
if(!error){
error = function(){};
}

if (reference === null) {
error("Null reference isn't supported");
return;
Expand All @@ -235,6 +301,12 @@ StorageHandle.prototype.getString = function(reference, success, error) {

/* object storage COMPOSITE AND DOESNT CARE FOR BROWSER*/
StorageHandle.prototype.putObject = function(reference, obj, success, error) {

//if error is null then replace with empty function to silence warnings
if(!error){
error = function(){};
}

var objAsString = "";
try {
objAsString = JSON.stringify(obj);
Expand All @@ -253,6 +325,12 @@ StorageHandle.prototype.putObject = function(reference, obj, success, error) {
};

StorageHandle.prototype.getObject = function(reference, success, error) {

//if error is null then replace with empty function to silence warnings
if(!error){
error = function(){};
}

this.getString(reference, function(data) {
var obj = {};
try {
Expand All @@ -266,6 +344,12 @@ StorageHandle.prototype.getObject = function(reference, success, error) {

/* API >= 2 */
StorageHandle.prototype.setItem = function(reference, obj, success, error) {

//if error is null then replace with empty function to silence warnings
if(!error){
error = function(){};
}

var objAsString = "";
try {
objAsString = JSON.stringify(obj);
Expand All @@ -290,6 +374,12 @@ StorageHandle.prototype.setItem = function(reference, obj, success, error) {
};

StorageHandle.prototype.getItem = function(reference, success, error) {

//if error is null then replace with empty function to silence warnings
if(!error){
error = function(){};
}

if (reference === null) {
error(new NativeStorageError(NativeStorageError.NULL_REFERENCE, "JS", ""));
return;
Expand All @@ -312,6 +402,12 @@ StorageHandle.prototype.getItem = function(reference, success, error) {

/* API >= 2 */
StorageHandle.prototype.setSecretItem = function(reference, obj, encryptConfig, success, error) {

//if error is null then replace with empty function to silence warnings
if(!error){
error = function(){};
}

var objAsString = "";
try {
objAsString = JSON.stringify(obj);
Expand Down Expand Up @@ -354,6 +450,12 @@ StorageHandle.prototype.setSecretItem = function(reference, obj, encryptConfig,
};

StorageHandle.prototype.getSecretItem = function(reference, encryptConfig, success, error) {

//if error is null then replace with empty function to silence warnings
if(!error){
error = function(){};
}

if (reference === null) {
error(new NativeStorageError(NativeStorageError.NULL_REFERENCE, "JS", ""));
return;
Expand Down Expand Up @@ -394,6 +496,12 @@ StorageHandle.prototype.getSecretItem = function(reference, encryptConfig, succe

/* list keys */
StorageHandle.prototype.keys = function(success, error) {

//if error is null then replace with empty function to silence warnings
if(!error){
error = function(){};
}

this.storageHandlerDelegate(success, error, "NativeStorage", "keys", []);
};

Expand Down

0 comments on commit 11cbc5a

Please sign in to comment.