private static IllegalArgumentException explainWrongLengthOrOffset(final byte[] bytes,
    final int offset, final int length, final int expectedLength) {
    String reason;
    if (length != expectedLength) {
      reason = "Wrong length: " + length + ", expected " + expectedLength;
    } else {
      reason = "offset (" + offset + ") + length (" + length + ") exceed the"
        + " capacity of the array: " + bytes.length;
    }
    return new IllegalArgumentException(reason);
  }
Converts a byte array to a long value.
@param bytes  array of bytes
@param offset offset into array
@param length length of data (must be {@link #SIZEOF_LONG})
@return the long value
@throws IllegalArgumentException if length is not {@link #SIZEOF_LONG} or if there's not enough
                                 room in the array at the offset indicated.
hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java