737 lines
32 KiB
MQL5
737 lines
32 KiB
MQL5
//+------------------------------------------------------------------+
| |||
//| ErrDescription.mqh |
| |||
//| Copyright 2026, Niquel Mendoza. |
| |||
//| https://www.mql5.com/es/users/nique_372 |
| |||
//+------------------------------------------------------------------+
| |||
#property copyright "Copyright 2026, Niquel Mendoza."
| |||
#property link "https://www.mql5.com/es/users/nique_372"
| |||
#property strict
| |||
| |||
| |||
#ifndef MQLARTICLES_UTILS_ERRDESCRIPTION_MQH
| |||
#define MQLARTICLES_UTILS_ERRDESCRIPTION_MQH
| |||
| |||
//+------------------------------------------------------------------+
| |||
//| |
| |||
//+------------------------------------------------------------------+
| |||
#define MQLARTICLES_FIRST_RUNTIME_ERROR ERR_SUCCESS
| |||
#define MQLARTICLES_LAST_RUNTIME_ERROR ERR_ONNX_WRONG_DIMENSION
| |||
#define MQLARTICLES_FIRST_TRADE_SERVER_ERROR TRADE_RETCODE_REQUOTE
| |||
#define MQLARTICLES_LAST_TRADE_SERVER_ERROR TRADE_RETCODE_HEDGE_PROHIBITED
| |||
| |||
//+------------------------------------------------------------------+
| |||
//| |
| |||
//+------------------------------------------------------------------+
| |||
class CMt5ErrorDesc
| |||
{
| |||
public:
| |||
CMt5ErrorDesc(void) {}
| |||
~CMt5ErrorDesc(void) {}
| |||
| |||
//---
| |||
static string TradeServerReturnCodeDescription(int return_code);
| |||
static string ErrorDescription(int error_code);
| |||
| |||
//---
| |||
static __forceinline bool IsSuccess(int return_code = -1);
| |||
static __forceinline bool IsTradeServerError(int return_code = -1);
| |||
static __forceinline bool IsRuntimeError(int return_code = -1);
| |||
static __forceinline bool IsUserError(int return_code = -1);
| |||
static void GetError(string& error_desc, int error_code = -1, bool include_code = true);
| |||
};
| |||
| |||
//+------------------------------------------------------------------+
| |||
//| Gets the Trade Server Return Code Description |
| |||
//+------------------------------------------------------------------+
| |||
static string CMt5ErrorDesc::TradeServerReturnCodeDescription(int return_code)
| |||
{
| |||
switch(return_code)
| |||
{
| |||
// ---
| |||
case TRADE_RETCODE_REQUOTE:
| |||
return("Requote");
| |||
case TRADE_RETCODE_REJECT:
| |||
return("Request rejected");
| |||
case TRADE_RETCODE_CANCEL:
| |||
return("Request canceled by trader");
| |||
case TRADE_RETCODE_PLACED:
| |||
return("Order placed");
| |||
case TRADE_RETCODE_DONE:
| |||
return("Request completed");
| |||
case TRADE_RETCODE_DONE_PARTIAL:
| |||
return("Only part of the request was completed");
| |||
case TRADE_RETCODE_ERROR:
| |||
return("Request processing error");
| |||
case TRADE_RETCODE_TIMEOUT:
| |||
return("Request canceled by timeout");
| |||
case TRADE_RETCODE_INVALID:
| |||
return("Invalid request");
| |||
case TRADE_RETCODE_INVALID_VOLUME:
| |||
return("Invalid volume in the request");
| |||
case TRADE_RETCODE_INVALID_PRICE:
| |||
return("Invalid price in the request");
| |||
case TRADE_RETCODE_INVALID_STOPS:
| |||
return("Invalid stops in the request");
| |||
case TRADE_RETCODE_TRADE_DISABLED:
| |||
return("Trade is disabled");
| |||
case TRADE_RETCODE_MARKET_CLOSED:
| |||
return("Market is closed");
| |||
case TRADE_RETCODE_NO_MONEY:
| |||
return("There is not enough money to complete the request");
| |||
case TRADE_RETCODE_PRICE_CHANGED:
| |||
return("Prices changed");
| |||
case TRADE_RETCODE_PRICE_OFF:
| |||
return("There are no quotes to process the request");
| |||
case TRADE_RETCODE_INVALID_EXPIRATION:
| |||
return("Invalid order expiration date in the request");
| |||
case TRADE_RETCODE_ORDER_CHANGED:
| |||
return("Order state changed");
| |||
case TRADE_RETCODE_TOO_MANY_REQUESTS:
| |||
return("Too frequent requests");
| |||
case TRADE_RETCODE_NO_CHANGES:
| |||
return("No changes in request");
| |||
case TRADE_RETCODE_SERVER_DISABLES_AT:
| |||
return("Autotrading disabled by server");
| |||
case TRADE_RETCODE_CLIENT_DISABLES_AT:
| |||
return("Autotrading disabled by client terminal");
| |||
case TRADE_RETCODE_LOCKED:
| |||
return("Request locked for processing");
| |||
case TRADE_RETCODE_FROZEN:
| |||
return("Order or position frozen");
| |||
case TRADE_RETCODE_INVALID_FILL:
| |||
return("Invalid order filling type");
| |||
case TRADE_RETCODE_CONNECTION:
| |||
return("No connection with the trade server");
| |||
case TRADE_RETCODE_ONLY_REAL:
| |||
return("Operation is allowed only for live accounts");
| |||
case TRADE_RETCODE_LIMIT_ORDERS:
| |||
return("The number of pending orders has reached the limit");
| |||
case TRADE_RETCODE_LIMIT_VOLUME:
| |||
return("The volume of orders and positions for the symbol has reached the limit");
| |||
case TRADE_RETCODE_INVALID_ORDER:
| |||
return("Incorrect or prohibited order type");
| |||
case TRADE_RETCODE_POSITION_CLOSED:
| |||
return("Position with the specified POSITION_IDENTIFIER has already been closed");
| |||
case TRADE_RETCODE_INVALID_CLOSE_VOLUME:
| |||
return("A close volume exceeds the current position volume");
| |||
case TRADE_RETCODE_CLOSE_ORDER_EXIST:
| |||
return("A close order already exists for a specified position");
| |||
case TRADE_RETCODE_LIMIT_POSITIONS:
| |||
return("The number of open positions simultaneously present on an account can be limited by the server settings");
| |||
case TRADE_RETCODE_REJECT_CANCEL:
| |||
return("The pending order activation request is rejected, the order is canceled");
| |||
case TRADE_RETCODE_LONG_ONLY:
| |||
return("The request is rejected, because the \"Only long positions are allowed\" rule is set for the symbol (POSITION_TYPE_BUY)");
| |||
case TRADE_RETCODE_SHORT_ONLY:
| |||
return("The request is rejected, because the \"Only short positions are allowed\" rule is set for the symbol (POSITION_TYPE_SELL)");
| |||
case TRADE_RETCODE_CLOSE_ONLY:
| |||
return("The request is rejected, because the \"Only position closing is allowed\" rule is set for the symbol");
| |||
case TRADE_RETCODE_FIFO_CLOSE:
| |||
return("The request is rejected, because \"Position closing is allowed only by FIFO rule\" flag is set for the trading account (ACCOUNT_FIFO_CLOSE=true)");
| |||
case TRADE_RETCODE_HEDGE_PROHIBITED:
| |||
return("The request is rejected, because the \"Opposite positions on a single symbol are disabled\" rule is set for the trading account");
| |||
}
| |||
// ---
| |||
return(NULL);
| |||
}
| |||
| |||
//+------------------------------------------------------------------+
| |||
//| Gets the Runtime Error Code Description |
| |||
//+------------------------------------------------------------------+
| |||
static string CMt5ErrorDesc::ErrorDescription(int error_code)
| |||
{
| |||
switch(error_code)
| |||
{
| |||
// ---
| |||
case ERR_SUCCESS:
| |||
return("The operation completed successfully");
| |||
case ERR_INTERNAL_ERROR:
| |||
return("Unexpected internal error");
| |||
case ERR_WRONG_INTERNAL_PARAMETER:
| |||
return("Wrong parameter in the inner call of the client terminal function");
| |||
case ERR_INVALID_PARAMETER:
| |||
return("Wrong parameter when calling the system function");
| |||
case ERR_NOT_ENOUGH_MEMORY:
| |||
return("Not enough memory to perform the system function");
| |||
case ERR_STRUCT_WITHOBJECTS_ORCLASS:
| |||
return("The structure contains objects of strings and/or dynamic arrays and/or structure of such objects and/or classes");
| |||
case ERR_INVALID_ARRAY:
| |||
return("Array of a wrong type, wrong size, or a damaged object of a dynamic array");
| |||
case ERR_ARRAY_RESIZE_ERROR:
| |||
return("Not enough memory for the relocation of an array, or an attempt to change the size of a static array");
| |||
case ERR_STRING_RESIZE_ERROR:
| |||
return("Not enough memory for the relocation of string");
| |||
case ERR_NOTINITIALIZED_STRING:
| |||
return("Not initialized string");
| |||
case ERR_INVALID_DATETIME:
| |||
return("Invalid date and/or time");
| |||
case ERR_ARRAY_BAD_SIZE:
| |||
return("Total amount of elements in the array cannot exceed 2147483647");
| |||
case ERR_INVALID_POINTER:
| |||
return("Wrong pointer");
| |||
case ERR_INVALID_POINTER_TYPE:
| |||
return("Wrong type of pointer");
| |||
case ERR_FUNCTION_NOT_ALLOWED:
| |||
return("Function is not allowed for call");
| |||
case ERR_RESOURCE_NAME_DUPLICATED:
| |||
return("The names of the dynamic and the static resource match");
| |||
case ERR_RESOURCE_NOT_FOUND:
| |||
return("Resource with this name has not been found in EX5");
| |||
case ERR_RESOURCE_UNSUPPORTED_TYPE:
| |||
return("Unsupported resource type or its size exceeds 16 Mb");
| |||
case ERR_RESOURCE_NAME_IS_TOO_LONG:
| |||
return("The resource name exceeds 63 characters");
| |||
case ERR_MATH_OVERFLOW:
| |||
return("Overflow occurred when calculating math function");
| |||
case ERR_SLEEP_ERROR:
| |||
return("Out of test end date after calling Sleep()");
| |||
case ERR_PROGRAM_STOPPED:
| |||
return("Test forcibly stopped from the outside");
| |||
case ERR_INVALID_TYPE:
| |||
return("Invalid type");
| |||
case ERR_INVALID_HANDLE:
| |||
return("Invalid handle");
| |||
case ERR_TOO_MANY_OBJECTS:
| |||
return("Object pool filled out");
| |||
// Charts
| |||
case ERR_CHART_WRONG_ID:
| |||
return("Wrong chart ID");
| |||
case ERR_CHART_NO_REPLY:
| |||
return("Chart does not respond");
| |||
case ERR_CHART_NOT_FOUND:
| |||
return("Chart not found");
| |||
case ERR_CHART_NO_EXPERT:
| |||
return("No Expert Advisor in the chart that could handle the event");
| |||
case ERR_CHART_CANNOT_OPEN:
| |||
return("Chart opening error");
| |||
case ERR_CHART_CANNOT_CHANGE:
| |||
return("Failed to change chart symbol and period");
| |||
case ERR_CHART_WRONG_PARAMETER:
| |||
return("Error value of the parameter for the function of working with charts");
| |||
case ERR_CHART_CANNOT_CREATE_TIMER:
| |||
return("Failed to create timer");
| |||
case ERR_CHART_WRONG_PROPERTY:
| |||
return("Wrong chart property ID");
| |||
case ERR_CHART_SCREENSHOT_FAILED:
| |||
return("Error creating screenshots");
| |||
case ERR_CHART_NAVIGATE_FAILED:
| |||
return("Error navigating through chart");
| |||
case ERR_CHART_TEMPLATE_FAILED:
| |||
return("Error applying template");
| |||
case ERR_CHART_WINDOW_NOT_FOUND:
| |||
return("Subwindow containing the indicator was not found");
| |||
case ERR_CHART_INDICATOR_CANNOT_ADD:
| |||
return("Error adding an indicator to chart");
| |||
case ERR_CHART_INDICATOR_CANNOT_DEL:
| |||
return("Error deleting an indicator from the chart");
| |||
case ERR_CHART_INDICATOR_NOT_FOUND:
| |||
return("Indicator not found on the specified chart");
| |||
// Graphical Objects
| |||
case ERR_OBJECT_ERROR:
| |||
return("Error working with a graphical object");
| |||
case ERR_OBJECT_NOT_FOUND:
| |||
return("Graphical object was not found");
| |||
case ERR_OBJECT_WRONG_PROPERTY:
| |||
return("Wrong ID of a graphical object property");
| |||
case ERR_OBJECT_GETDATE_FAILED:
| |||
return("Unable to get date corresponding to the value");
| |||
case ERR_OBJECT_GETVALUE_FAILED:
| |||
return("Unable to get value corresponding to the date");
| |||
// MarketInfo
| |||
case ERR_MARKET_UNKNOWN_SYMBOL:
| |||
return("Unknown symbol");
| |||
case ERR_MARKET_NOT_SELECTED:
| |||
return("Symbol is not selected in MarketWatch");
| |||
case ERR_MARKET_WRONG_PROPERTY:
| |||
return("Wrong identifier of a symbol property");
| |||
case ERR_MARKET_LASTTIME_UNKNOWN:
| |||
return("Time of the last tick is not known (no ticks)");
| |||
case ERR_MARKET_SELECT_ERROR:
| |||
return("Error adding or deleting a symbol in MarketWatch");
| |||
// History Access
| |||
case ERR_HISTORY_NOT_FOUND:
| |||
return("Requested history not found");
| |||
case ERR_HISTORY_WRONG_PROPERTY:
| |||
return("Wrong ID of the history property");
| |||
case ERR_HISTORY_TIMEOUT:
| |||
return("Exceeded history request timeout");
| |||
case ERR_HISTORY_BARS_LIMIT:
| |||
return("Number of requested bars limited by terminal settings");
| |||
case ERR_HISTORY_LOAD_ERRORS:
| |||
return("Multiple errors when loading history");
| |||
case ERR_HISTORY_SMALL_BUFFER:
| |||
return("Receiving array is too small to store all requested data");
| |||
// Global_Variables
| |||
case ERR_GLOBALVARIABLE_NOT_FOUND:
| |||
return("Global variable of the client terminal is not found");
| |||
case ERR_GLOBALVARIABLE_EXISTS:
| |||
return("Global variable of the client terminal with the same name already exists");
| |||
case ERR_GLOBALVARIABLE_NOT_MODIFIED:
| |||
return("Global variables were not modified");
| |||
case ERR_GLOBALVARIABLE_CANNOTREAD:
| |||
return("Cannot read file with global variable values");
| |||
case ERR_GLOBALVARIABLE_CANNOTWRITE:
| |||
return("Cannot write file with global variable values");
| |||
case ERR_MAIL_SEND_FAILED:
| |||
return("Email sending failed");
| |||
case ERR_PLAY_SOUND_FAILED:
| |||
return("Sound playing failed");
| |||
case ERR_MQL5_WRONG_PROPERTY:
| |||
return("Wrong identifier of the program property");
| |||
case ERR_TERMINAL_WRONG_PROPERTY:
| |||
return("Wrong identifier of the terminal property");
| |||
case ERR_FTP_SEND_FAILED:
| |||
return("File sending via ftp failed");
| |||
case ERR_NOTIFICATION_SEND_FAILED:
| |||
return("Failed to send a notification");
| |||
case ERR_NOTIFICATION_WRONG_PARAMETER:
| |||
return("Invalid parameter for sending a notification – an empty string or NULL has been passed to the SendNotification() function");
| |||
case ERR_NOTIFICATION_WRONG_SETTINGS:
| |||
return("Wrong settings of notifications in the terminal (ID is not specified or permission is not set)");
| |||
case ERR_NOTIFICATION_TOO_FREQUENT:
| |||
return("Too frequent sending of notifications");
| |||
case ERR_FTP_NOSERVER:
| |||
return("FTP server is not specified");
| |||
case ERR_FTP_NOLOGIN:
| |||
return("FTP login is not specified");
| |||
case ERR_FTP_FILE_ERROR:
| |||
return("File not found in the MQL5/Files directory to send on FTP server");
| |||
case ERR_FTP_CONNECT_FAILED:
| |||
return("FTP connection failed");
| |||
case ERR_FTP_CHANGEDIR:
| |||
return("FTP path not found on server");
| |||
// Custom Indicator Buffers
| |||
case ERR_BUFFERS_NO_MEMORY:
| |||
return("Not enough memory for the distribution of indicator buffers");
| |||
case ERR_BUFFERS_WRONG_INDEX:
| |||
return("Wrong indicator buffer index");
| |||
// Custom Indicator Properties
| |||
case ERR_CUSTOM_WRONG_PROPERTY:
| |||
return("Wrong ID of the custom indicator property");
| |||
// Account
| |||
case ERR_ACCOUNT_WRONG_PROPERTY:
| |||
return("Wrong account property ID");
| |||
case ERR_TRADE_WRONG_PROPERTY:
| |||
return("Wrong trade property ID");
| |||
case ERR_TRADE_DISABLED:
| |||
return("Trading by Expert Advisors prohibited");
| |||
case ERR_TRADE_POSITION_NOT_FOUND:
| |||
return("Position not found");
| |||
case ERR_TRADE_ORDER_NOT_FOUND:
| |||
return("Order not found");
| |||
case ERR_TRADE_DEAL_NOT_FOUND:
| |||
return("Deal not found");
| |||
case ERR_TRADE_SEND_FAILED:
| |||
return("Trade request sending failed");
| |||
case ERR_TRADE_CALC_FAILED:
| |||
return("Failed to calculate profit or margin");
| |||
// Indicators
| |||
case ERR_INDICATOR_UNKNOWN_SYMBOL:
| |||
return("Unknown symbol");
| |||
case ERR_INDICATOR_CANNOT_CREATE:
| |||
return("Indicator cannot be created");
| |||
case ERR_INDICATOR_NO_MEMORY:
| |||
return("Not enough memory to add the indicator");
| |||
case ERR_INDICATOR_CANNOT_APPLY:
| |||
return("The indicator cannot be applied to another indicator");
| |||
case ERR_INDICATOR_CANNOT_ADD:
| |||
return("Error applying an indicator to chart");
| |||
case ERR_INDICATOR_DATA_NOT_FOUND:
| |||
return("Requested data not found");
| |||
case ERR_INDICATOR_WRONG_HANDLE:
| |||
return("Wrong indicator handle");
| |||
case ERR_INDICATOR_WRONG_PARAMETERS:
| |||
return("Wrong number of parameters when creating an indicator");
| |||
case ERR_INDICATOR_PARAMETERS_MISSING:
| |||
return("No parameters when creating an indicator");
| |||
case ERR_INDICATOR_CUSTOM_NAME:
| |||
return("The first parameter in the array must be the name of the custom indicator");
| |||
case ERR_INDICATOR_PARAMETER_TYPE:
| |||
return("Invalid parameter type in the array when creating an indicator");
| |||
case ERR_INDICATOR_WRONG_INDEX:
| |||
return("Wrong index of the requested indicator buffer");
| |||
// Depth of Market
| |||
case ERR_BOOKS_CANNOT_ADD:
| |||
return("Depth Of Market can not be added");
| |||
case ERR_BOOKS_CANNOT_DELETE:
| |||
return("Depth Of Market can not be removed");
| |||
case ERR_BOOKS_CANNOT_GET:
| |||
return("The data from Depth Of Market can not be obtained");
| |||
case ERR_BOOKS_CANNOT_SUBSCRIBE:
| |||
return("Error in subscribing to receive new data from Depth Of Market");
| |||
// File Operations
| |||
case ERR_TOO_MANY_FILES:
| |||
return("More than 64 files cannot be opened at the same time");
| |||
case ERR_WRONG_FILENAME:
| |||
return("Invalid file name");
| |||
case ERR_TOO_LONG_FILENAME:
| |||
return("Too long file name");
| |||
case ERR_CANNOT_OPEN_FILE:
| |||
return("File opening error");
| |||
case ERR_FILE_CACHEBUFFER_ERROR:
| |||
return("Not enough memory for cache to read");
| |||
case ERR_CANNOT_DELETE_FILE:
| |||
return("File deleting error");
| |||
case ERR_INVALID_FILEHANDLE:
| |||
return("A file with this handle was closed, or was not opening at all");
| |||
case ERR_WRONG_FILEHANDLE:
| |||
return("Wrong file handle");
| |||
case ERR_FILE_NOTTOWRITE:
| |||
return("The file must be opened for writing");
| |||
case ERR_FILE_NOTTOREAD:
| |||
return("The file must be opened for reading");
| |||
case ERR_FILE_NOTBIN:
| |||
return("The file must be opened as a binary one");
| |||
case ERR_FILE_NOTTXT:
| |||
return("The file must be opened as a text");
| |||
case ERR_FILE_NOTTXTORCSV:
| |||
return("The file must be opened as a text or CSV");
| |||
case ERR_FILE_NOTCSV:
| |||
return("The file must be opened as CSV");
| |||
case ERR_FILE_READERROR:
| |||
return("File reading error");
| |||
case ERR_FILE_BINSTRINGSIZE:
| |||
return("String size must be specified, because the file is opened as binary");
| |||
case ERR_INCOMPATIBLE_FILE:
| |||
return("A text file must be for string arrays, for other arrays - binary");
| |||
case ERR_FILE_IS_DIRECTORY:
| |||
return("This is not a file, this is a directory");
| |||
case ERR_FILE_NOT_EXIST:
| |||
return("File does not exist");
| |||
case ERR_FILE_CANNOT_REWRITE:
| |||
return("File can not be rewritten");
| |||
case ERR_WRONG_DIRECTORYNAME:
| |||
return("Wrong directory name");
| |||
case ERR_DIRECTORY_NOT_EXIST:
| |||
return("Directory does not exist");
| |||
case ERR_FILE_ISNOT_DIRECTORY:
| |||
return("This is a file, not a directory");
| |||
case ERR_CANNOT_DELETE_DIRECTORY:
| |||
return("The directory cannot be removed");
| |||
case ERR_CANNOT_CLEAN_DIRECTORY:
| |||
return("Failed to clear the directory (probably one or more files are blocked and removal operation failed)");
| |||
case ERR_FILE_WRITEERROR:
| |||
return("Failed to write a resource to a file");
| |||
case ERR_FILE_ENDOFFILE:
| |||
return("Unable to read the next piece of data from a CSV file (FileReadString, FileReadNumber, FileReadDatetime, FileReadBool), since the end of file is reached");
| |||
// String Casting
| |||
case ERR_NO_STRING_DATE:
| |||
return("No date in the string");
| |||
case ERR_WRONG_STRING_DATE:
| |||
return("Wrong date in the string");
| |||
case ERR_WRONG_STRING_TIME:
| |||
return("Wrong time in the string");
| |||
case ERR_STRING_TIME_ERROR:
| |||
return("Error converting string to date");
| |||
case ERR_STRING_OUT_OF_MEMORY:
| |||
return("Not enough memory for the string");
| |||
case ERR_STRING_SMALL_LEN:
| |||
return("The string length is less than expected");
| |||
case ERR_STRING_TOO_BIGNUMBER:
| |||
return("Too large number, more than ULONG_MAX");
| |||
case ERR_WRONG_FORMATSTRING:
| |||
return("Invalid format string");
| |||
case ERR_TOO_MANY_FORMATTERS:
| |||
return("Amount of format specifiers more than the parameters");
| |||
case ERR_TOO_MANY_PARAMETERS:
| |||
return("Amount of parameters more than the format specifiers");
| |||
case ERR_WRONG_STRING_PARAMETER:
| |||
return("Damaged parameter of string type");
| |||
case ERR_STRINGPOS_OUTOFRANGE:
| |||
return("Position outside the string");
| |||
case ERR_STRING_ZEROADDED:
| |||
return("0 added to the string end, a useless operation");
| |||
case ERR_STRING_UNKNOWNTYPE:
| |||
return("Unknown data type when converting to a string");
| |||
case ERR_WRONG_STRING_OBJECT:
| |||
return("Damaged string object");
| |||
// Operations with Arrays
| |||
case ERR_INCOMPATIBLE_ARRAYS:
| |||
return("Copying incompatible arrays");
| |||
case ERR_SMALL_ASSERIES_ARRAY:
| |||
return("The receiving array is declared as AS_SERIES, and it is of insufficient size");
| |||
case ERR_SMALL_ARRAY:
| |||
return("Too small array, the starting position is outside the array");
| |||
case ERR_ZEROSIZE_ARRAY:
| |||
return("An array of zero length");
| |||
case ERR_NUMBER_ARRAYS_ONLY:
| |||
return("Must be a numeric array");
| |||
case ERR_ONEDIM_ARRAYS_ONLY:
| |||
return("Must be a one-dimensional array");
| |||
case ERR_SERIES_ARRAY:
| |||
return("Timeseries cannot be used");
| |||
case ERR_DOUBLE_ARRAY_ONLY:
| |||
return("Must be an array of type double");
| |||
case ERR_FLOAT_ARRAY_ONLY:
| |||
return("Must be an array of type float");
| |||
case ERR_LONG_ARRAY_ONLY:
| |||
return("Must be an array of type long");
| |||
case ERR_INT_ARRAY_ONLY:
| |||
return("Must be an array of type int");
| |||
case ERR_SHORT_ARRAY_ONLY:
| |||
return("Must be an array of type short");
| |||
case ERR_CHAR_ARRAY_ONLY:
| |||
return("Must be an array of type char");
| |||
case ERR_STRING_ARRAY_ONLY:
| |||
return("String array only");
| |||
// Operations with OpenCL
| |||
case ERR_OPENCL_NOT_SUPPORTED:
| |||
return("OpenCL functions are not supported on this computer");
| |||
case ERR_OPENCL_INTERNAL:
| |||
return("Internal error occurred when running OpenCL");
| |||
case ERR_OPENCL_INVALID_HANDLE:
| |||
return("Invalid OpenCL handle");
| |||
case ERR_OPENCL_CONTEXT_CREATE:
| |||
return("Error creating the OpenCL context");
| |||
case ERR_OPENCL_QUEUE_CREATE:
| |||
return("Failed to create a run queue in OpenCL");
| |||
case ERR_OPENCL_PROGRAM_CREATE:
| |||
return("Error occurred when compiling an OpenCL program");
| |||
case ERR_OPENCL_TOO_LONG_KERNEL_NAME:
| |||
return("Too long kernel name (OpenCL kernel)");
| |||
case ERR_OPENCL_KERNEL_CREATE:
| |||
return("Error creating an OpenCL kernel");
| |||
case ERR_OPENCL_SET_KERNEL_PARAMETER:
| |||
return("Error occurred when setting parameters for the OpenCL kernel");
| |||
case ERR_OPENCL_EXECUTE:
| |||
return("OpenCL program runtime error");
| |||
case ERR_OPENCL_WRONG_BUFFER_SIZE:
| |||
return("Invalid size of the OpenCL buffer");
| |||
case ERR_OPENCL_WRONG_BUFFER_OFFSET:
| |||
return("Invalid offset in the OpenCL buffer");
| |||
case ERR_OPENCL_BUFFER_CREATE:
| |||
return("Failed to create an OpenCL buffer");
| |||
case ERR_OPENCL_TOO_MANY_OBJECTS:
| |||
return("Too many OpenCL objects");
| |||
case ERR_OPENCL_SELECTDEVICE:
| |||
return("OpenCL device selection error");
| |||
// Working with databases
| |||
case ERR_DATABASE_INTERNAL:
| |||
return("Internal database error");
| |||
case ERR_DATABASE_INVALID_HANDLE:
| |||
return("Invalid database handle");
| |||
case ERR_DATABASE_TOO_MANY_OBJECTS:
| |||
return("Exceeded the maximum acceptable number of Database objects");
| |||
case ERR_DATABASE_CONNECT:
| |||
return("Database connection error");
| |||
case ERR_DATABASE_EXECUTE:
| |||
return("Request execution error");
| |||
case ERR_DATABASE_PREPARE:
| |||
return("Request generation error");
| |||
case ERR_DATABASE_NO_MORE_DATA:
| |||
return("No more data to read");
| |||
case ERR_DATABASE_STEP:
| |||
return("Failed to move to the next request entry");
| |||
case ERR_DATABASE_NOT_READY:
| |||
return("Data for reading request results are not ready yet");
| |||
case ERR_DATABASE_BIND_PARAMETERS:
| |||
return("Failed to auto substitute parameters to an SQL request");
| |||
// Operations with WebRequest
| |||
case ERR_WEBREQUEST_INVALID_ADDRESS:
| |||
return("Invalid URL");
| |||
case ERR_WEBREQUEST_CONNECT_FAILED:
| |||
return("Failed to connect to specified URL");
| |||
case ERR_WEBREQUEST_TIMEOUT:
| |||
return("Timeout exceeded");
| |||
case ERR_WEBREQUEST_REQUEST_FAILED:
| |||
return("HTTP request failed");
| |||
// Operations with network (sockets)
| |||
case ERR_NETSOCKET_INVALIDHANDLE:
| |||
return("Invalid socket handle passed to function");
| |||
case ERR_NETSOCKET_TOO_MANY_OPENED:
| |||
return("Too many open sockets (max 128)");
| |||
case ERR_NETSOCKET_CANNOT_CONNECT:
| |||
return("Failed to connect to remote host");
| |||
case ERR_NETSOCKET_IO_ERROR:
| |||
return("Failed to send/receive data from socket");
| |||
case ERR_NETSOCKET_HANDSHAKE_FAILED:
| |||
return("Failed to establish secure connection (TLS Handshake)");
| |||
case ERR_NETSOCKET_NO_CERTIFICATE:
| |||
return("No data on certificate protecting the connection");
| |||
// Custom Symbols
| |||
case ERR_NOT_CUSTOM_SYMBOL:
| |||
return("A custom symbol must be specified");
| |||
case ERR_CUSTOM_SYMBOL_WRONG_NAME:
| |||
return("The name of the custom symbol is invalid");
| |||
case ERR_CUSTOM_SYMBOL_NAME_LONG:
| |||
return("The name of the custom symbol is too long");
| |||
case ERR_CUSTOM_SYMBOL_PATH_LONG:
| |||
return("The path of the custom symbol is too long");
| |||
case ERR_CUSTOM_SYMBOL_EXIST:
| |||
return("A custom symbol with the same name already exists");
| |||
case ERR_CUSTOM_SYMBOL_ERROR:
| |||
return("Error occurred while creating, deleting or changing the custom symbol");
| |||
case ERR_CUSTOM_SYMBOL_SELECTED:
| |||
return("You are trying to delete a custom symbol selected in Market Watch");
| |||
case ERR_CUSTOM_SYMBOL_PROPERTY_WRONG:
| |||
return("An invalid custom symbol property");
| |||
case ERR_CUSTOM_SYMBOL_PARAMETER_ERROR:
| |||
return("A wrong parameter while setting the property of a custom symbol");
| |||
case ERR_CUSTOM_SYMBOL_PARAMETER_LONG:
| |||
return("A too long string parameter while setting the property of a custom symbol");
| |||
case ERR_CUSTOM_TICKS_WRONG_ORDER:
| |||
return("Ticks in the array are not arranged in the order of time");
| |||
// Economic Calendar
| |||
case ERR_CALENDAR_MORE_DATA:
| |||
return("Array size is insufficient for receiving descriptions of all values");
| |||
case ERR_CALENDAR_TIMEOUT:
| |||
return("Request time limit exceeded");
| |||
case ERR_CALENDAR_NO_DATA:
| |||
return("Country is not found");
| |||
// Working with databases
| |||
case ERR_DATABASE_ERROR:
| |||
return("Generic error");
| |||
case ERR_DATABASE_LOGIC:
| |||
return("SQLite internal logic error");
| |||
case ERR_DATABASE_PERM:
| |||
return("Access denied");
| |||
case ERR_DATABASE_ABORT:
| |||
return("Callback routine requested abort");
| |||
case ERR_DATABASE_BUSY:
| |||
return("Database file locked");
| |||
case ERR_DATABASE_LOCKED:
| |||
return("Database table locked");
| |||
case ERR_DATABASE_NOMEM:
| |||
return("Insufficient memory for completing operation");
| |||
case ERR_DATABASE_READONLY:
| |||
return("Attempt to write to readonly database");
| |||
case ERR_DATABASE_INTERRUPT:
| |||
return("Operation terminated by sqlite3_interrupt()");
| |||
case ERR_DATABASE_IOERR:
| |||
return("Disk I/O error");
| |||
case ERR_DATABASE_CORRUPT:
| |||
return("Database disk image corrupted");
| |||
case ERR_DATABASE_NOTFOUND:
| |||
return("Unknown operation code in sqlite3_file_control()");
| |||
case ERR_DATABASE_FULL:
| |||
return("Insertion failed because database is full");
| |||
case ERR_DATABASE_CANTOPEN:
| |||
return("Unable to open the database file");
| |||
case ERR_DATABASE_PROTOCOL:
| |||
return("Database lock protocol error");
| |||
case ERR_DATABASE_EMPTY:
| |||
return("Internal use only");
| |||
case ERR_DATABASE_SCHEMA:
| |||
return("Database schema changed");
| |||
case ERR_DATABASE_TOOBIG:
| |||
return("String or BLOB exceeds size limit");
| |||
case ERR_DATABASE_CONSTRAINT:
| |||
return("Abort due to constraint violation");
| |||
case ERR_DATABASE_MISMATCH:
| |||
return("Data type mismatch");
| |||
case ERR_DATABASE_MISUSE:
| |||
return("Library used incorrectly");
| |||
case ERR_DATABASE_NOLFS:
| |||
return("Uses OS features not supported on host");
| |||
case ERR_DATABASE_AUTH:
| |||
return("Authorization denied");
| |||
case ERR_DATABASE_FORMAT:
| |||
return("Not used");
| |||
case ERR_DATABASE_RANGE:
| |||
return("Bind parameter error, incorrect index");
| |||
case ERR_DATABASE_NOTADB:
| |||
return("File opened that is not database file");
| |||
// Matrix and Vector Methods
| |||
case ERR_MATRIX_INTERNAL:
| |||
return("Internal error of the matrix/vector executing subsystem");
| |||
case ERR_MATRIX_NOT_INITIALIZED:
| |||
return("Matrix/vector not initialized");
| |||
case ERR_MATRIX_INCONSISTENT:
| |||
return("Inconsistent size of matrices/vectors in operation");
| |||
case ERR_MATRIX_INVALID_SIZE:
| |||
return("Invalid matrix/vector size");
| |||
case ERR_MATRIX_INVALID_TYPE:
| |||
return("Invalid matrix/vector type");
| |||
case ERR_MATRIX_FUNC_NOT_ALLOWED:
| |||
return("Function not available for this matrix/vector");
| |||
case ERR_MATRIX_CONTAINS_NAN:
| |||
return("Matrix/vector contains non-numbers (Nan/Inf)");
| |||
// ONNX models
| |||
case ERR_ONNX_INTERNAL:
| |||
return("ONNX internal error");
| |||
case ERR_ONNX_NOT_INITIALIZED:
| |||
return("ONNX Runtime API initialization error");
| |||
case ERR_ONNX_NOT_SUPPORTED:
| |||
return("Property or value not supported by MQL5");
| |||
case ERR_ONNX_RUN_FAILED:
| |||
return("ONNX runtime API run error");
| |||
case ERR_ONNX_INVALID_PARAMETERS_COUNT:
| |||
return("Invalid number of parameters passed to OnnxRun");
| |||
case ERR_ONNX_INVALID_PARAMETER:
| |||
return("Invalid parameter value");
| |||
case ERR_ONNX_INVALID_PARAMETER_TYPE:
| |||
return("Invalid parameter type");
| |||
case ERR_ONNX_INVALID_PARAMETER_SIZE:
| |||
return("Invalid parameter size");
| |||
case ERR_ONNX_WRONG_DIMENSION:
| |||
return("Tensor dimension not set or invalid");
| |||
// User-Defined Errors
| |||
default:
| |||
if(error_code >= ERR_USER_ERROR_FIRST && error_code < ERR_USER_ERROR_LAST)
| |||
return("User error " + string(error_code - ERR_USER_ERROR_FIRST));
| |||
}
| |||
// ---
| |||
return(NULL);
| |||
}
| |||
| |||
//+------------------------------------------------------------------+
| |||
//| Checks whether the operation was completed successfully. |
| |||
//+------------------------------------------------------------------+
| |||
static __forceinline bool CMt5ErrorDesc::IsSuccess(int return_code = -1)
| |||
{
| |||
if(return_code == -1)
| |||
return_code = ::GetLastError();
| |||
return(return_code == ERR_SUCCESS);
| |||
}
| |||
| |||
//+------------------------------------------------------------------+
| |||
//| Checks whether an return code is a Trade Server Error. |
| |||
//+------------------------------------------------------------------+
| |||
static __forceinline bool CMt5ErrorDesc::IsTradeServerError(int return_code = -1)
| |||
{
| |||
if(return_code == -1)
| |||
return_code = ::GetLastError();
| |||
return(return_code >= MQLARTICLES_FIRST_TRADE_SERVER_ERROR && return_code <= MQLARTICLES_LAST_TRADE_SERVER_ERROR);
| |||
}
| |||
| |||
//+------------------------------------------------------------------+
| |||
//| Checks whether an return code is a Runtime Error. |
| |||
//+------------------------------------------------------------------+
| |||
static __forceinline bool CMt5ErrorDesc::IsRuntimeError(int return_code = -1)
| |||
{
| |||
if(return_code == -1)
| |||
return_code = ::GetLastError();
| |||
return(return_code >= MQLARTICLES_FIRST_RUNTIME_ERROR && return_code <= MQLARTICLES_LAST_RUNTIME_ERROR);
| |||
}
| |||
| |||
//+------------------------------------------------------------------+
| |||
//| Checks whether an return code is a User-Defined Error. |
| |||
//+------------------------------------------------------------------+
| |||
static __forceinline bool CMt5ErrorDesc::IsUserError(int return_code = -1)
| |||
{
| |||
if(return_code == -1)
| |||
return_code = ::GetLastError();
| |||
return(return_code >= ERR_USER_ERROR_FIRST && return_code < ERR_USER_ERROR_LAST);
| |||
}
| |||
| |||
| |||
//+------------------------------------------------------------------+
| |||
//| Gets the Error Code Description. |
| |||
//+------------------------------------------------------------------+
| |||
static void CMt5ErrorDesc::GetError(string& error_desc, int error_code = -1, bool include_code = true)
| |||
{
| |||
//--- get last error code
| |||
if(error_code == -1)
| |||
error_code = ::GetLastError();
| |||
//--- get error description
| |||
if(IsTradeServerError(error_code))
| |||
error_desc = TradeServerReturnCodeDescription(error_code);
| |||
else
| |||
error_desc = ErrorDescription(error_code);
| |||
//--- include error code in description
| |||
if(error_desc != NULL && include_code)
| |||
error_desc = StringFormat("%s [%d]", error_desc, error_code);
| |||
}
| |||
| |||
//+------------------------------------------------------------------+
| |||
#endif // MQLARTICLES_UTILS_ERRDESCRIPTION_MQH
|