Skip to content

Commit b2423b1

Browse files
author
Nathanael Anderson
committed
Cleanup error checks.
1 parent 19747db commit b2423b1

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

test-app/runtime/src/main/cpp/MetadataNode.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,7 +1799,7 @@ void MetadataNode::BuildMetadata(const string& filesPath) {
17991799

18001800
// TODO: Is there a way to detect if the screen is locked as verification
18011801
// We assume based on the error that this is the only way to get this specific error here at this point
1802-
if (errno == 2) {
1802+
if (errno == ENOENT) {
18031803
// Log the error with error code
18041804
__android_log_print(ANDROID_LOG_ERROR, "TNS.error", "%s", ss.str().c_str());
18051805

@@ -1829,7 +1829,12 @@ void MetadataNode::BuildMetadata(const string& filesPath) {
18291829

18301830
FILE* f = fopen(nodesFile.c_str(), "rb");
18311831
if (f == nullptr) {
1832-
throw NativeScriptException(string("metadata file (treeNodeStream.dat) couldn't be opened!"));
1832+
stringstream ss;
1833+
ss << "metadata file (treeNodeStream.dat) couldn't be opened! (Error: ";
1834+
ss << errno;
1835+
ss << ") ";
1836+
1837+
throw NativeScriptException(ss.str());
18331838
}
18341839
fseek(f, 0, SEEK_END);
18351840
int lenNodes = ftell(f);
@@ -1843,7 +1848,11 @@ void MetadataNode::BuildMetadata(const string& filesPath) {
18431848

18441849
f = fopen(namesFile.c_str(), "rb");
18451850
if (f == nullptr) {
1846-
throw NativeScriptException(string("metadata file (treeStringsStream.dat) couldn't be opened!"));
1851+
stringstream ss;
1852+
ss << "metadata file (treeStringsStream.dat) couldn't be opened! (Error: ";
1853+
ss << errno;
1854+
ss << ") ";
1855+
throw NativeScriptException(ss.str());
18471856
}
18481857
fseek(f, 0, SEEK_END);
18491858
int lenNames = ftell(f);
@@ -1854,7 +1863,11 @@ void MetadataNode::BuildMetadata(const string& filesPath) {
18541863

18551864
f = fopen(valuesFile.c_str(), "rb");
18561865
if (f == nullptr) {
1857-
throw NativeScriptException(string("metadata file (treeValueStream.dat) couldn't be opened!"));
1866+
stringstream ss;
1867+
ss << "metadata file (treeValueStream.dat) couldn't be opened! (Error: ";
1868+
ss << errno;
1869+
ss << ") ";
1870+
throw NativeScriptException(ss.str());
18581871
}
18591872
fseek(f, 0, SEEK_END);
18601873
int lenValues = ftell(f);

0 commit comments

Comments
 (0)