1 package net.sumaris.core.exception; 2 3 /*- 4 * #%L 5 * SUMARiS :: Sumaris Core Shared 6 * $Id:$ 7 * $HeadURL:$ 8 * %% 9 * Copyright (C) 2018 SUMARiS Consortium 10 * %% 11 * This program is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as 13 * published by the Free Software Foundation, either version 3 of the 14 * License, or (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public 22 * License along with this program. If not, see 23 * <http://www.gnu.org/licenses/gpl-3.0.html>. 24 * #L% 25 */ 26 27 28 import net.sumaris.shared.exception.ErrorCodes; 29 30 /** 31 * Technical exception 32 * 33 * @author Benoit Lavenier <benoit.lavenier@e-is.pro> 34 */ 35 public class SumarisTechnicalException extends RuntimeException { 36 37 private static final long serialVersionUID = ErrorCodes.INTERNAL_ERROR; 38 39 private final int code; 40 41 /** 42 * <p>Constructor for SumarisTechnicalException.</p> 43 * 44 * @param message a {@link String} object. 45 */ 46 public SumarisTechnicalException(String message) { 47 super(message); 48 this.code = ErrorCodes.INTERNAL_ERROR; 49 } 50 51 /** 52 * <p>Constructor for SumarisTechnicalException.</p> 53 * 54 * @param cause a {@link Throwable} object. 55 */ 56 public SumarisTechnicalException(Throwable cause) { 57 super(cause); 58 this.code = ErrorCodes.INTERNAL_ERROR; 59 } 60 61 /** 62 * <p>Constructor for SumarisTechnicalException.</p> 63 * 64 * @param message a {@link String} object. 65 * @param cause a {@link Throwable} object. 66 */ 67 public SumarisTechnicalException(String message, Throwable cause) { 68 super(message, cause); 69 this.code = ErrorCodes.INTERNAL_ERROR; 70 } 71 72 /** 73 * <p>Constructor for SumarisTechnicalException.</p> 74 * 75 * @param code a {@link int} for error code. 76 * @param message a {@link String} object. 77 */ 78 public SumarisTechnicalException(int code, String message) { 79 super(message); 80 this.code = code; 81 } 82 83 /** 84 * <p>Constructor for SumarisTechnicalException.</p> 85 * 86 * @param code a {@link int} for error code. 87 * @param message a {@link String} object. 88 * @param cause a {@link Throwable} object. 89 */ 90 public SumarisTechnicalException(int code, String message, Throwable cause) { 91 super(message, cause); 92 this.code = code; 93 } 94 95 /** 96 * <p>Constructor for SumarisTechnicalException.</p> 97 * 98 * @param code a {@link int} for error code. 99 * @param cause a {@link Throwable} object. 100 */ 101 public SumarisTechnicalException(int code, Throwable cause) { 102 super(cause); 103 this.code = code; 104 } 105 106 107 /** 108 * Get the error code 109 * @return 110 */ 111 public int getCode() { 112 return this.code; 113 } 114 }