function handleError(res) {
  try {
    const e = JSON.parse(res.text).errors.shift();
    errorInfo.innerHTML = `${e.type} for "${e.value}": ${e.message}.`;
  } catch (ex) {
    errorInfo.innerHTML = 'An unexpected error occurred.';
  }

  toggleVisibility(errorInfo, true);
  toggleVisibility(successInfo, false);
  toggleVisibility(tokenInfo, false);
} // handleError
/**
 * Render error message. If the response has a JSON "text" attribute which
 * contains an array of errors, display the error type and message for the
 * first item in that array, otherwise just display a generic message.
 *
 * @param {Object} res - The response object
 */
Render error message. If the response has a JSON "text" attribute which
contains an array of errors, display the error type and message for the
first item in that array, otherwise just display a generic message.

@param {Object} res - The response object
Render error message . If the response has a JSON " text " attribute which contains an array of errors display the error type and message for the first item in that array otherwise just display a generic message . @param { Object } res - The response object
function handleError(res) {
  try {
    const e = JSON.parse(res.text).errors.shift();
    errorInfo.innerHTML = `${e.type} for "${e.value}": ${e.message}.`;
  } catch (ex) {
    errorInfo.innerHTML = 'An unexpected error occurred.';
  }
  toggleVisibility(errorInfo, true);
  toggleVisibility(successInfo, false);
  toggleVisibility(tokenInfo, false);
} 
function handleError ( res ) { try { const e = JSON . parse ( res . text ) . errors . shift ( ) ; errorInfo . innerHTML = ` ${ e . type } ${ e . value } ${ e . message } ` ; } catch ( ex ) { errorInfo . innerHTML = 'An unexpected error occurred.' ; } toggleVisibility ( errorInfo , true ) ; toggleVisibility ( successInfo , false ) ; toggleVisibility ( tokenInfo , false ) ; }
Render error message.
Render error message .
// handleError