Displaying an error message in alertcontroller

Greetings!

I’m trying to check if the user entered his/her password correctly or not. I want to display the error messages on a alertcontroller.

 updatePassword() {
    let alert = this.alertCtrl.create({
      inputs: [
        {
          name: 'oldPassword',
          placeholder: 'Old password',
          type: 'password'
        },
        {
          name: 'newPassword',
          placeholder: 'New password',
          type: 'password'
        },
      ],
      buttons: [
        {
          text: 'Cancel',
        },
        {
          text: 'Save',
          handler: data => {
            if (!this.settings.updatePassword(data.newPassword, data.oldPassword)) {
              let alert = this.alertCtrl.create({
                message: "Password Changed Successfully!, Please login again!",
                buttons: [
                  {
                    text: "Ok",
                    role: 'cancel'
                  }
                ]
              });
              alert.present();
            }
            else if (this.settings.updatePassword(data.newPassword, data.oldPassword)){
              (error) => {
                this.loading.dismiss().then(() => {
                  var errorMessage: string = error.message;
                  let alert = this.alertCtrl.create({
                    message: errorMessage,
                    buttons: [
                      {
                        text: "Ok",
                        role: 'cancel'
                      }
                    ]
                  });
                  alert.present();
                });
              }
            }



          }
        }
      ]
    });
    alert.present();
  }

I’m getting an error saying that dismiss is undefined. How can I solve this?