title: Code works, but is it best practice to have a try/catch block inside a promise?
body: <p>Is it good practice to wrap a <code>try/catch</code> with a <code>Promise</code>? I was reviewing the code below, I cannot seem to understand the necessity of having a <code>try/catch</code> block inside a <code>Promise</code>. Also, why would there be no place where the <code>Promise</code> rejects, as you can see in the <code>catch</code> block, the <code>Promise</code> resolves. Please help me understand this piece of code, in terms of best practice and efficiency the point of having the <code>try/catch</code> inside the <code>Promise</code>.</p>
  
  <p>I would also really appreciate any suggestions regarding cleaning the code up where it is redundant.</p>
  
  <pre><code>getRoute(): any {
      return async (request: any, reply: any) =&gt; {
        const result = new Promise&lt;string&gt;( async (resolve, reject) =&gt; {
          try {
            let userIsValid = await this.validator.validate(request.payload, RegisterUserValidator);
            if (userIsValid.error) {
              resolve(responseHelper.getErrorResponse(ResponseErrorCode.joiValidatorError, userIsValid.error));
              throw new ControlFlowNonError();
            }
            let results = await this.authUser.registerUser(request.payload);
            resolve(responseHelper.getSuccessResponse(results, null));
          }
          catch (error) {
            let message: ILogMessage = {
              code: ResponseErrorCode.unknownError,
              message: ResponseErrorCode.unknownError.toString(),
              meta: error,
              sourceFunction : 'ApiDataCreateCredentials: getRoute()'
            };
            this.logHelper.error(message);
            resolve(error);
          }
        });
        reply(result);
      };
    };
  </code></pre>