Thursday, March 7, 2019

throwing errors in JavaScript!

This will kick off the else condition below:

try {
   throw 'Can you see this?';
}
catch(error){
   if (error.message){
      this.loggingContract.Log(error.message);
   } else {
      this.loggingContract.Log(error);
   }
}

 
 

In contrast, this matches the criteria at the if, falling into the first conditional:

try {
   throw Error('Can you see this?');
}
catch(error){
   if (error.message){
      this.loggingContract.Log(error.message);
   } else {
      this.loggingContract.Log(error);
   }
}

 
 

In both cases I am trying to boil the error down to a string.

No comments:

Post a Comment