diff --git a/common/libeval_compiler/libeval_compiler.cpp b/common/libeval_compiler/libeval_compiler.cpp
index ecaa2f31ab..e841d675a6 100644
--- a/common/libeval_compiler/libeval_compiler.cpp
+++ b/common/libeval_compiler/libeval_compiler.cpp
@@ -605,7 +605,7 @@ void CONTEXT::ReportError( const wxString& aErrorMsg )
     m_errorStatus.stage = CST_RUNTIME;
 
     if( m_errorCallback )
-        m_errorCallback( m_errorStatus );
+        m_errorCallback( m_errorStatus.message, m_errorStatus.srcPos );
 }
 
 
@@ -779,7 +779,7 @@ bool COMPILER::generateUCode( UCODE* aCode, CONTEXT* aPreflightContext )
                     //    leaf[0]: function name
                     //    leaf[1]: parameter
 
-                    wxString    itemName = *node->leaf[0]->value.str;
+                    wxString                 itemName = *node->leaf[0]->value.str;
                     std::unique_ptr<VAR_REF> vref = aCode->CreateVarRef( itemName, "" );
 
                     if( !vref )
@@ -802,15 +802,19 @@ bool COMPILER::generateUCode( UCODE* aCode, CONTEXT* aPreflightContext )
                     if( func )
                     {
                         // Preflight the function call
-                        wxString paramStr;
+                        wxString paramStr = *node->leaf[1]->leaf[1]->value.str;
+                        VALUE*   param = aPreflightContext->AllocValue();
 
-                        if( node->value.str )
-                            paramStr = *node->value.str;
-
-                        VALUE*  param = aPreflightContext->AllocValue();
                         param->Set( paramStr );
                         aPreflightContext->Push( param );
 
+                        aPreflightContext->SetErrorCallback(
+                                [&]( const wxString& aMessage, int aOffset )
+                                {
+                                    size_t loc = node->leaf[1]->leaf[1]->srcPos- paramStr.Length();
+                                    reportError( CST_CODEGEN, aMessage, (int) loc - 1 );
+                                } );
+
                         try
                         {
                             func( aPreflightContext, vref.get() );
@@ -819,13 +823,6 @@ bool COMPILER::generateUCode( UCODE* aCode, CONTEXT* aPreflightContext )
                         catch( ... )
                         {
                         }
-
-                        if( !aPreflightContext->IsErrorPending() )
-                        {
-                            size_t loc = node->leaf[1]->leaf[1]->srcPos - paramStr.Length();
-                            reportError( CST_CODEGEN, aPreflightContext->GetError().message,
-                                         (int) loc - 1 );
-                        }
                     }
 
                     node->leaf[0]->isVisited = true;
diff --git a/include/libeval_compiler/libeval_compiler.h b/include/libeval_compiler/libeval_compiler.h
index 992dfe2dc4..c657c6783e 100644
--- a/include/libeval_compiler/libeval_compiler.h
+++ b/include/libeval_compiler/libeval_compiler.h
@@ -285,7 +285,11 @@ public:
         return m_stack.size();
     };
 
-    void SetErrorCallback( std::function<void(const ERROR_STATUS&)> aCallback );
+    void SetErrorCallback( std::function<void( const wxString& aMessage, int aOffset )> aCallback )
+    {
+        m_errorCallback = std::move( aCallback );
+    }
+
     void ReportError( const wxString& aErrorMsg );
     bool IsErrorPending() const { return m_errorStatus.pendingError; }
     const ERROR_STATUS& GetError() const { return m_errorStatus; }
@@ -294,7 +298,8 @@ private:
     std::vector<VALUE*> m_ownedValues;
     std::stack<VALUE*>  m_stack;
     ERROR_STATUS        m_errorStatus;
-    std::function<void(const ERROR_STATUS&)> m_errorCallback;
+
+    std::function<void( const wxString& aMessage, int aOffset )> m_errorCallback;
 };