Try-catch not working for DialogBox

Hi i am facing some issue in try catch as it is not able to detect error.

Situation → On the webpage i am entering data and click save. The record saved when no error in data but throws error (Show a dialog box) when data is corrupt.

Steps i tried - > Basically put the save in the try and dialog handler in catch but not working.
it is not going to catch block as save is clicked.

I tested dialog handler separately working fine so how to have dialog handler on specific events means when they appear.