function formatError()

in cdslogviewer/frontend/app/common/format_error.ts [12:35]


function formatError(error: any, brief: boolean) {
  if (error.response) {
    // The request was made and the server responded with a status code
    // that falls out of the range of 2xx
    return (
      `Server error ${error.response.status}: ` +
      bestErrorString(error.response.data, brief)
    );
  } else if (error.request) {
    // The request was made but no response was received
    // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
    // http.ClientRequest in node.js
    console.error("Failed request: ", error.request);
    return brief
      ? "No response"
      : "No response from server. See console log for more details.";
  } else {
    // Something happened in setting up the request that triggered an Error
    console.error("Axios error setting up request: ", error.message);
    return brief
      ? "Couldn't send"
      : "Unable to set up request. See console log for more details.";
  }
}