001 package com.github.sarxos.webcam;
002
003 import java.lang.Thread.UncaughtExceptionHandler;
004
005 import org.slf4j.Logger;
006 import org.slf4j.LoggerFactory;
007
008
009 public class WebcamExceptionHandler implements UncaughtExceptionHandler {
010
011 private static final Logger LOG = LoggerFactory.getLogger(WebcamExceptionHandler.class);
012
013 private static final WebcamExceptionHandler INSTANCE = new WebcamExceptionHandler();
014
015 private WebcamExceptionHandler() {
016 // singleton
017 }
018
019 @Override
020 public void uncaughtException(Thread t, Throwable e) {
021 LOG.error(String.format("Exception in thread %s", t.getName()), e);
022 System.err.println(String.format("Exception in thread %s", t.getName()));
023 e.printStackTrace();
024 }
025
026 protected static final WebcamExceptionHandler getInstance() {
027 return INSTANCE;
028 }
029 }