usb4java/src/main/java/org/libusb4java/LibUsbException.java

61 lines
1.6 KiB
Java

/*
* Copyright 2013 Klaus Reimer <k@ailis.de>
* See LICENSE.md for licensing information.
*
* Based on libusb <http://www.libusb.org/>:
*
* Copyright 2001 Johannes Erdfelt <johannes@erdfelt.com>
* Copyright 2007-2009 Daniel Drake <dsd@gentoo.org>
* Copyright 2010-2012 Peter Stuge <peter@stuge.se>
* Copyright 2008-2011 Nathan Hjelm <hjelmn@users.sourceforge.net>
* Copyright 2009-2012 Pete Batard <pete@akeo.ie>
* Copyright 2009-2012 Ludovic Rousseau <ludovic.rousseau@gmail.com>
* Copyright 2010-2012 Michael Plante <michael.plante@gmail.com>
* Copyright 2011-2012 Hans de Goede <hdegoede@redhat.com>
* Copyright 2012 Martin Pieuchot <mpi@openbsd.org>
* Copyright 2012-2013 Toby Gray <toby.gray@realvnc.com>
*/
package org.usb4java.libusb;
import javax.usb.UsbException;
/**
* libusb-specific USB exception.
*
* @author Klaus Reimer (k@ailis.de)
*/
public final class LibUsbException extends UsbException
{
/** Serial version UID. */
private static final long serialVersionUID = 1L;
/** The error code. */
private final int errorCode;
/**
* Constructor.
*
* @param message
* The error message.
* @param errorCode
* The error code.
*/
public LibUsbException(final String message, final int errorCode)
{
super(String.format("USB error %d: %s: %s", -errorCode, message,
LibUsb.strError(errorCode)));
this.errorCode = errorCode;
}
/**
* Returns the error code.
*
* @return The error code
*/
public int getErrorCode()
{
return this.errorCode;
}
}