org.usb4java.javax.ExceptionUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of usb4java-javax Show documentation
Show all versions of usb4java-javax Show documentation
Extension for usb4java which implements javax.usb (JSR-80).
The newest version!
/*
* Copyright 2014 Klaus Reimer
* See LICENSE.md for licensing information.
*/
package org.usb4java.javax;
import javax.usb.UsbPlatformException;
import org.usb4java.LibUsb;
/**
* Utility methods for exception handling.
*
* @author Klaus Reimer ([email protected])
*/
final class ExceptionUtils
{
/**
* Private constructor to prevent instantiation.
*/
private ExceptionUtils()
{
// Empty
}
/**
* Creates a USB platform exception.
*
* @param message
* The error message.
* @param errorCode
* The error code.
* @return The USB platform exception.
*/
static UsbPlatformException createPlatformException(final String message,
final int errorCode)
{
return new UsbPlatformException(String.format("USB error %d: %s: %s",
-errorCode, message, LibUsb.strError(errorCode)), errorCode);
}
}