All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.usb4java.javax.ExceptionUtils Maven / Gradle / Ivy

There is a newer version: 1.3.0
Show 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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy