From 3498d3a97edc55893be3d9c50a43217878ca15bf Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Wed, 14 Mar 2012 01:29:33 +0000 Subject: [PATCH] add explicit exception for unsupported encodings git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@617 f203690c-595d-4dc9-a70b-905162fa7fd2 --- .../jackcess/DefaultCodecProvider.java | 6 +-- .../jackcess/UnsupportedCodecException.java | 48 +++++++++++++++++++ 2 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 src/java/com/healthmarketscience/jackcess/UnsupportedCodecException.java diff --git a/src/java/com/healthmarketscience/jackcess/DefaultCodecProvider.java b/src/java/com/healthmarketscience/jackcess/DefaultCodecProvider.java index 76280b9..e24634a 100644 --- a/src/java/com/healthmarketscience/jackcess/DefaultCodecProvider.java +++ b/src/java/com/healthmarketscience/jackcess/DefaultCodecProvider.java @@ -99,21 +99,21 @@ public class DefaultCodecProvider implements CodecProvider /** * CodecHandler implementation which always throws - * UnsupportedOperationException, useful for databases with unsupported + * UnsupportedCodecException, useful for databases with unsupported * encodings. */ public static class UnsupportedHandler implements CodecHandler { public void decodePage(ByteBuffer page, int pageNumber) throws IOException { - throw new UnsupportedOperationException("Decoding not supported"); + throw new UnsupportedCodecException("Decoding not supported. Please choose a CodecProvider which supports reading the current database encoding."); } public ByteBuffer encodePage(ByteBuffer page, int pageNumber, int pageOffset) throws IOException { - throw new UnsupportedOperationException("Encoding not supported"); + throw new UnsupportedCodecException("Encoding not supported. Please choose a CodecProvider which supports writing the current database encoding."); } } diff --git a/src/java/com/healthmarketscience/jackcess/UnsupportedCodecException.java b/src/java/com/healthmarketscience/jackcess/UnsupportedCodecException.java new file mode 100644 index 0000000..51b772c --- /dev/null +++ b/src/java/com/healthmarketscience/jackcess/UnsupportedCodecException.java @@ -0,0 +1,48 @@ +/* +Copyright (c) 2012 James Ahlborn + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA +*/ + +package com.healthmarketscience.jackcess; + +/** + * Exception thrown by a CodecHandler to indicate that the current encoding is + * not supported. This generally indicates that a different CodecProvider + * needs to be chosen. + * + * @author James Ahlborn + */ +public class UnsupportedCodecException + extends UnsupportedOperationException +{ + private static final long serialVersionUID = 20120313L; + + public UnsupportedCodecException(String msg) + { + super(msg); + } + + public UnsupportedCodecException(String msg, Throwable t) + { + super(msg, t); + } + + public UnsupportedCodecException(Throwable t) + { + super(t); + } +} -- 2.39.5