Commit 1490042060f9d95015605057f4ec178c025b91bd

Authored by Nathanael Jourdane
1 parent a244a5d9
Exists in master and in 1 other branch b6.0.X

Add VOTable specific exceptions.

src/main/java/eu/omp/irap/vespa/votable/controller/CantGetVOTableException.java renamed to src/main/java/eu/omp/irap/vespa/votable/controller/VOTableException.java
... ... @@ -22,7 +22,7 @@ package eu.omp.irap.vespa.votable.controller;
22 22 *
23 23 * @author N. Jourdane
24 24 */
25   -public class CantGetVOTableException extends Exception {
  25 +public abstract class VOTableException extends Exception {
26 26  
27 27 /** The serial version UID. */
28 28 private static final long serialVersionUID = 1L;
... ... @@ -33,7 +33,7 @@ public class CantGetVOTableException extends Exception {
33 33 *
34 34 * @param message The message describing the exception.
35 35 */
36   - public CantGetVOTableException(String message) {
  36 + public VOTableException(String message) {
37 37 super(message);
38 38 }
39 39  
... ... @@ -43,7 +43,59 @@ public class CantGetVOTableException extends Exception {
43 43 * @param message The message describing the exception.
44 44 * @param e The exception.
45 45 */
46   - public CantGetVOTableException(String message, Exception e) {
  46 + public VOTableException(String message, Exception e) {
47 47 super(message, e);
48 48 }
  49 +
  50 +
  51 + /** An exception thrown when we can not read the VOTable. */
  52 + public static class CantReadVOTableException extends VOTableException {
  53 +
  54 + /** The serial version UID. */
  55 + private static final long serialVersionUID = 1L;
  56 +
  57 +
  58 + /**
  59 + * @param voTablePath The path of the VOTable.
  60 + * @param e The exception thrown.
  61 + */
  62 + public CantReadVOTableException(String voTablePath, Exception e) {
  63 + super("Can not read the VOTable which should be stored in: " + voTablePath, e);
  64 + }
  65 + }
  66 +
  67 + /** An exception thrown when we can not get the VOTable, ie. an error in the query. */
  68 + public static class CantGetVOTableException extends VOTableException {
  69 +
  70 + /** The serial version UID. */
  71 + private static final long serialVersionUID = 1L;
  72 +
  73 +
  74 + /**
  75 + * @param voTableRequest The path of the VOTable.
  76 + * @param e The exception thrown.
  77 + */
  78 + public CantGetVOTableException(String voTableRequest, Exception e) {
  79 + super("Can not get the remote VOTable with the request: " + voTableRequest, e);
  80 + }
  81 + }
  82 +
  83 + /**
  84 + * An exception thrown when the VOTable is not valid, ie. it don't have the expected body.
  85 + */
  86 + public static class VOTableIsNotValidException extends VOTableException {
  87 +
  88 + /** The serial version UID. */
  89 + private static final long serialVersionUID = 1L;
  90 +
  91 +
  92 + /**
  93 + * @param voTablePath The path of the VOTable.
  94 + * @param e The exception thrown.
  95 + */
  96 + public VOTableIsNotValidException(String voTablePath) {
  97 + super("Can not parse the VOTable because it doesn't match with the VOTable schema."
  98 + + "\n See the VOTable file for more details: " + voTablePath);
  99 + }
  100 + }
49 101 }
50 102 \ No newline at end of file
... ...