Error message for wrong username or password

I am trying to build a shiny app where users need to give credentials to connect with database. If users give correct credentials then the app will load and will show a table, but if the credentials are wrong then they will get a message instead of R error.

library(shiny)

data <- function(x, y){
  con <- dbConnect(RMySQL::MySQL(), 
                  dbname = "tweater", 
                  host = "courses.csrrinzqubik.us-east-1.rds.amazonaws.com", 
                  port = 3306,
                  user = x,
                  password = y)
  
  users <- dbReadTable(con, "users")
  return(users)
}

ui <- fluidPage(
  titlePanel(title = "Shiny LogIN"),
  fluidRow(
    column(2, 
           textInput('username', 'User Name'),
           passwordInput('pass', 'Password'),
           actionButton('submit', 'Submit')),
    column(8, 
           shinycssloaders::withSpinner(tableOutput('table')))
  )
)

server <- function(input, output, session) {
  
  y <- eventReactive(input$submit,{
    x <- data(x = input$username, y = input$pass)
    head(x)
  })
  
  output$table <- renderTable({
    y()
  })
}

shinyApp(ui, server)

How to replace the R error message with an alert when users give wrong credentials? Consider user name as 'student' and password as 'datacamp'.
There might be chance that the username or password is not unique so if(input$username) != 'student' or if(input$pass) != 'datacamp' cann't be used.

I would use base::tryCatch to handle errors.
Exceptions and debugging ยท Advanced R. (had.co.nz)

There are many options to show messages/alerts to users on shiny apps.
Some examples might be found in
shinyalerts package
shinyjs::alert()
shinyWidgets::alert()