1 package com.nilhcem.fakesmtp.core.exception;
2
3 /**
4 * Abstract class to simplify creation of exceptions due to a SMTP port error.
5 *
6 * @author Nilhcem
7 * @since 1.0
8 */
9 abstract class AbstractPortException extends Exception {
10 private static final long serialVersionUID = 9011196541962512429L;
11 private final int port;
12
13 /**
14 * Copies the stack trace of the exception passed in parameter, and sets the port which caused the exception.
15 *
16 * @param e the exception we need to copy the stack trace from.
17 * @param port the selected port which was the cause of the exception.
18 */
19 public AbstractPortException(Exception e, int port) {
20 setStackTrace(e.getStackTrace());
21 this.port = port;
22 }
23
24 /**
25 * Returns the port entered by the user.
26 * <p>
27 * Useful to know why the SMTP server could not start.
28 * </p>
29 *
30 * @return the port which caused the exception.
31 */
32 public int getPort() {
33 return port;
34 }
35 }