001// Copyright (c) FIRST and other WPILib contributors. 002// Open Source Software; you can modify and/or share it under the terms of 003// the WPILib BSD license file in the root directory of this project. 004 005package edu.wpi.first.epilogue.logging.errors; 006 007import edu.wpi.first.epilogue.logging.ClassSpecificLogger; 008 009/** 010 * An error handler implementation that will throw an exception if logging raised an exception. This 011 * is useful when running code in simulation or in JUnit tests to quickly identify errors in your 012 * code. 013 */ 014public class CrashOnError implements ErrorHandler { 015 /** Default constructor. */ 016 public CrashOnError() {} 017 018 @Override 019 public void handle(Throwable exception, ClassSpecificLogger<?> logger) { 020 throw new RuntimeException( 021 "[EPILOGUE] An error occurred while logging an instance of " 022 + logger.getLoggedType().getName(), 023 exception); 024 } 025}