Skip to content

Commit 3ed94ab

Browse files
committed
p21read should exit(1) for write errors _and_ read errors
1 parent 96fdcf9 commit 3ed94ab

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/test/p21read/p21read.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ extern void SchemaInit( class Registry & );
1818
#include <STEPattribute.h>
1919
#include <ExpDict.h>
2020
#include <Registry.h>
21+
#include <errordesc.h>
2122
#include <algorithm>
2223
#include <string>
2324
#include <unistd.h>
@@ -138,6 +139,8 @@ int main( int argc, char * argv[] ) {
138139

139140
checkSchemaName( registry, sfile, ignoreErr );
140141

142+
Severity readSev = sfile.Error().severity(); //otherwise, errors from reading will be wiped out by sfile.WriteExchangeFile()
143+
141144
cout << "EXAMPLE : write file ..." << endl;
142145
if( argc == optind+2 ) {
143146
flnm = argv[optind+1];
@@ -148,7 +151,7 @@ int main( int argc, char * argv[] ) {
148151
sfile.Error().PrintContents(cout);
149152
cout << flnm << " written" << endl;
150153

151-
if( sfile.Error().severity() <= SEVERITY_INCOMPLETE ) { //lower is worse
154+
if( ( sfile.Error().severity() <= SEVERITY_INCOMPLETE ) || ( readSev <= SEVERITY_INCOMPLETE ) ) { //lower is worse
152155
exit(1);
153156
}
154157
}

0 commit comments

Comments
 (0)