title: How can I handle an exception message with TypeScript?
body: <p>My code that I have looks like this:</p>
  
  <pre><code>class UserService implements IUserService {
  
      data: IUserServiceData = {
          expirationDate: null,
          isAuthenticated: false,
      };
  
      static $inject = [];
  
      constructor () {}
  
      isAuthenticated = () =&gt; {
          if (this.data.isAuthenticated &amp;&amp; !this.isAuthenticationExpired(this.data.expirationDate)) {
              return true;
          } else {
              try {
                  this.retrieveSavedData();
              } catch (e) {
                  return false;
                  // throw new NoAuthenticationException('Authentication not found');
              }
              return true;
          }
      };
  
      // Original Javascript code here
      //function AuthenticationRetrievalException(message) {
      //    this.name = 'AuthenticationRetrieval';
      //   this.message = message;
      //}
  
      AuthenticationRetrievalException = (message) =&gt; {
          this.name = 'AuthenticationRetrieval';
          this.message = message;
      }
  
      retrieveSavedData = () =&gt; {
          var savedData = this.utilityService.userCache.get('data');
          if (typeof savedData === 'undefined') {
              throw new AuthenticationRetrievalException('No authentication data exists');
          } else if (isAuthenticationExpired(savedData.expirationDate)) {
              throw new AuthenticationExpiredException('Authentication token has already expired');
          } else {
              this.data = savedData;
              this.setHttpAuthHeader();
          }
      }
  
  
  } 
  </code></pre>
  
  <p>What should I do with the this. references that were in my JavaScript source before I started to try and convert it?</p>
  
  <p>I don't know how to code this part in Typescript:</p>
  
  <pre><code>    AuthenticationRetrievalException = (message) =&gt; {
          this.name = 'AuthenticationRetrieval';
          this.message = message;
      }
  </code></pre>