/* * Copyright @ 2013 CurisTEC, S.A.S. All Rights Reserved. */ package net.curisit.securis.services.exception; /** * SeCurisServiceException *
* Checked exception for service-layer errors with an attached numeric error code. * Extends {@link CurisException} and is intended to be translated to HTTP responses * by upstream exception mappers/handlers. * * Usage: * - Prefer specific {@code ErrorCodes.*} when throwing. * - Use the single-arg constructor to default to UNEXPECTED_ERROR. * * @author JRA * Last reviewed by JRA on Oct 5, 2025. */ public class SeCurisServiceException extends CurisException { /** Numeric error code associated with this exception. */ private int errorCode = 0; /** * Constructor with explicit error code. * * @param errorCode See {@link ErrorCodes}. * @param msg Human-readable message (safe to expose). */ public SeCurisServiceException(int errorCode, String msg) { super(msg); this.errorCode = errorCode; } /** * Constructor defaulting to {@link ErrorCodes#UNEXPECTED_ERROR}. * * @param msg Human-readable message (safe to expose). */ public SeCurisServiceException(String msg) { super(msg); this.errorCode = ErrorCodes.UNEXPECTED_ERROR; } /** * getStatus *
* Returns the stored numeric error code. * * @return integer error code. */ public int getStatus() { return errorCode; } private static final long serialVersionUID = 1L; /** * ErrorCodes *
* Canonical set of service-layer error codes. * Grouped by feature areas (1000 generic, 11xx license, 12xx request data, 13xx validation). */ public static class ErrorCodes { public static int UNEXPECTED_ERROR = 1000; public static int INVALID_CREDENTIALS = 1001; public static int UNAUTHORIZED_ACCESS = 1002; public static int NOT_FOUND = 1003; public static int INVALID_FORMAT = 1004; public static int WRONG_STATUS = 1005; public static int UNNECESSARY_RENEW = 1006; public static int INVALID_LICENSE_REQUEST_DATA = 1100; public static int LICENSE_NOT_READY_FOR_RENEW = 1101; public static int LICENSE_DATA_IS_NOT_VALID = 1102; public static int LICENSE_IS_EXPIRED = 1103; public static int LICENSE_PACK_IS_NOT_VALID = 1104; public static int INVALID_REQUEST_DATA = 1201; public static int INVALID_REQUEST_DATA_FORMAT = 1202; public static int BLOCKED_REQUEST_DATA = 1203; public static int DUPLICATED_REQUEST_DATA = 1204; public static int NO_AVAILABLE_LICENSES = 1205; public static int INVALID_DATA = 1301; } }