Skip to content

Error reporting

Reporting errors is a crucial aspect of software development and system management for maintaining the health, performance, and user satisfaction of your software, applications, and systems.

Frontend

While error reporting to backend services or monitoring tools like Sentry is essential for identifying and resolving issues, communicating errors directly to users on the frontend provides a seamless and transparent experience, and helps the developers to resolve issues. For example:

sh
// Frontend Error Communication
function handleSubmit() {
  try {
    // Code to submit form and handle response
    if (response.status === 200) {
      // Success, perform desired actions
    } else if (response.status === 400) {
      // Display frontend error message to user
      showErrorPopup("Sorry, there was a problem with your submission. Please check your inputs and try again.")
    } else {
      // Handle other response statuses
    }
  } catch (error) {
    // Handle unexpected errors
    showErrorPopup("An unexpected error occurred. Please try again later.")
  }
}

Sentry

Sentry's error reporting prowess swiftly identifies issues at Beaulieu Canada, ensuring seamless user experiences throughout our tech landscape. To send errors to Sentry, you would capture and report errors where needed in your application code. For example:

sh
<script setup lang="ts">
import * as Sentry from '@sentry/browser'

  const fetchData = async () => {
    try {
      // Your code to fetch data
    } catch (error) {
      // Report the error to Sentry
      Sentry.captureException(error);
    }
  }

  const { data, error } = getData()
  if (error) {
    // Report the error to Sentry
    Sentry.captureException(error)
  }
  useData(data)
</script>

Released under the MIT License.