Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

ErrorDescription - Updated Library - Library for MetaTrader 5 - MT4/MT5 Resources

author EAcpu | 5 reads | 0 comments |

The library uses a short descriptive text for each error that appears in the MQL5 Reference. It is updated frequently as new bugs are added to the official documentation

Last updated: 2024-02-29

(Don’t forget to copy the file error description 2.mq5 to the folder \MetaTrader 5\MQL5\Include)

 //+------------------------------------------------------------------+
//| test.mq5 |
//| Copyright 2024, Paulo Enrique |
//| https://www.mql5.com/en/users/pau1ohenrique.dev |
//+------------------------------------------------------------------+
#Property Copyright "Copyright 2024, Paulo Enrique"
#Property association "https://www.mql5.com/en/users/pau1ohenrique.dev"
# Property version "1.00"

// include
#include <error description 2.mqh> //+----------------------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
blank start ()
  { //--- Usage example #1 print ( "MQL5 error description: " );
for ( integer i=FIRST_RUNTIME_ERROR;i<=LAST_TRADE_SERVER_ERROR;i++)
    {
stringerror_desc =GetError(i);
if (IsSuccess(i) || error_desc== invalid )
continue ;
if (IsRuntimeError(i))
print ( "Runtime error:" , error description);
if (IsTradeServerError(i))
print ( "Trading Server Error:" , error description);
if (IsUserError(i))
print ( "User Error:" , error description);
    } //--- Usage example #2 print ( "\nLast error description: " );
integerrecode = getLastError ();
if (!IsSuccess(recode))
print (GetError(recode)); //--- or simply print (getError());
// The operation completed successfully [0] // Unexpected internal error [4001] // ... print (getError( err ));
// Operation completed successfully // Unexpected internal error // ... } //+----------------------------------------------------------------------------------+

I will soon release a library with classes that simplify the use of errors in MQL5, including simplified user error reporting using the Raise(my_error) method, etc.


Attachment download

📎 errordescription2.mqh (32.92 KB)

📎 test.mq5 (1.73 KB)

Source: MQL5 #48431

Verification code Refresh