You can add 'try catch' block to the code
try{
throw new NotImplementedException();
}catch(Exception ex){
lblErrorMessage.Text=ex.Message;
}
so, you can catch the error message and print it on a label.
Still the better version is to check the duplication before submit button. Using ajax call on the Textbox's lost focus (change) event. It will take some time and will be little complex.