Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
User93
Contributor III
Contributor III

Create file on error

Hi all,

I would like to create an app which, upon encountering an error while in a reload task, would create a file with the text "error" in it.

So far, I know how to generate a .txt file with STORE into, but I can't find a way to generate the file for every possible error that might be encountered, and I also would like a file with only one line for "Error", instead of the multiple line :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<QvdTableHeader>
<QvBuildNo>50689</QvBuildNo>

...

For the error, I know there is ErrorMode, but I would like something that works for all possible errors, and within a reload task.

Is there a way to do it whith ErrorMode, or with something else ?

Best regards.

Labels (1)
2 Solutions

Accepted Solutions
TheLazyDeveloper
Contributor III
Contributor III

Maybe something like this added to your script and in sections to capture your error messages.

SET ErrorMode = 0;

LOAD * FROM [YourDataSource.qvd] (qvd);

// Capture error details if the previous load failed
SET vCustomErrMessage = '$(ScriptErrorDetails)';

 

ErrorLog:
LOAD
Now() as ErrorTimestamp,
'Section Name' as ScriptSection, // Replace with the actual section name
'$(vCustomErrMessage)' as ErrorMessage,
'$(ScriptErrorCount)' as ErrorCount;

Store ErrorLog into ErrorLog.csv (TXT); 

View solution in original post

rafaelencinas
Partner - Creator II
Partner - Creator II

Hi @User93 

When you get this text

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<QvdTableHeader>
<QvBuildNo>50689</QvBuildNo>

 

It means that when you store your QVD you forget to put in the end of store  .qvd(qvd)

 

Bye!

Senior Qlik Architect
Cobra, Stallone, "You're a problem and I'm the solution"

View solution in original post

4 Replies
TheLazyDeveloper
Contributor III
Contributor III

Maybe something like this added to your script and in sections to capture your error messages.

SET ErrorMode = 0;

LOAD * FROM [YourDataSource.qvd] (qvd);

// Capture error details if the previous load failed
SET vCustomErrMessage = '$(ScriptErrorDetails)';

 

ErrorLog:
LOAD
Now() as ErrorTimestamp,
'Section Name' as ScriptSection, // Replace with the actual section name
'$(vCustomErrMessage)' as ErrorMessage,
'$(ScriptErrorCount)' as ErrorCount;

Store ErrorLog into ErrorLog.csv (TXT); 

rafaelencinas
Partner - Creator II
Partner - Creator II

Hi @User93 

When you get this text

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<QvdTableHeader>
<QvBuildNo>50689</QvBuildNo>

 

It means that when you store your QVD you forget to put in the end of store  .qvd(qvd)

 

Bye!

Senior Qlik Architect
Cobra, Stallone, "You're a problem and I'm the solution"
User93
Contributor III
Contributor III
Author

Thanks !

It does solve the number of lines issue.

User93
Contributor III
Contributor III
Author

Thank you !

After a few tests, I ended with this :

SET ErrorMode = 0;

Load query

if ScriptErrorCount>0 then

File:

Load
'Error' AS [Error]

AutoGenerate 1

;

STORE File Into 'lib://Test/Test_Error.txt'(TXT);

Drop Table File;

end if

And it does work !