Example #1
0
        /// <summary>
        /// Generates EmoEngineException
        /// </summary>
        /// <param name="errorCode">error code returned from APIs from edk.dll</param>
        public static void errorHandler(Int32 errorCode)
        {
            if (errorCode == EdkDll.EDK_OK)
                return;

            string errorStr = "";
            switch (errorCode)
            {
                case EdkDll.EDK_INVALID_PROFILE_ARCHIVE:
                    errorStr = "Invalid profile archive";
                    break;
                case EdkDll.EDK_NO_USER_FOR_BASEPROFILE:
                    errorStr = "The base profile does not have a user ID";
                    break;
                case EdkDll.EDK_CANNOT_ACQUIRE_DATA:
                    errorStr = "EmoEngine is unable to acquire EEG input data";
                    break;
                case EdkDll.EDK_BUFFER_TOO_SMALL:
                    errorStr = "A supplied buffer is not large enough";
                    break;
                case EdkDll.EDK_OUT_OF_RANGE:
                    errorStr = "Parameter is out of range";
                    break;
                case EdkDll.EDK_INVALID_PARAMETER:
                    errorStr = "Parameter is invalid";
                    break;
                case EdkDll.EDK_PARAMETER_LOCKED:
                    errorStr = "Parameter is locked";
                    break;
                case EdkDll.EDK_INVALID_USER_ID:
                    errorStr = "User ID supplied to the function is invalid";
                    break;
                case EdkDll.EDK_EMOENGINE_UNINITIALIZED:
                    errorStr = "EmoEngine has not been initialized";
                    break;
                case EdkDll.EDK_EMOENGINE_DISCONNECTED:
                    errorStr = "Connection with remote instance of EmoEngine has been lost";
                    break;
                case EdkDll.EDK_EMOENGINE_PROXY_ERROR:
                    errorStr = "Unable to establish connection with remote instance of EmoEngine.";
                    break;
                case EdkDll.EDK_NO_EVENT:
                    errorStr = "There are no new EmoEngine events at this time.";
                    break;
                case EdkDll.EDK_GYRO_NOT_CALIBRATED:
                    errorStr = "The gyro could not be calibrated.  The headset must remain still for at least 0.5 secs.";
                    break;
                case EdkDll.EDK_OPTIMIZATION_IS_ON:
                    errorStr = "The requested operation failed due to optimization settings.";
                    break;
                case EdkDll.EDK_UNKNOWN_ERROR:
                    errorStr = "Unknown error";
                    break;
                default:
                    errorStr = "Unknown error";
                    break;
            }

            EmoEngineException exception = new EmoEngineException(errorStr);
            exception.ErrorCode = errorCode;
            throw exception;
        }