Skip to content

Commit

Permalink
Merge branch 'return-string-on-describe-error' into sruffell-active
Browse files Browse the repository at this point in the history
  • Loading branch information
sruffell committed Aug 14, 2020
2 parents 7ba8b97 + eff3c36 commit d40cc91
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
41 changes: 28 additions & 13 deletions src/commands/CmdDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,41 @@
////////////////////////////////////////////////////////////////////////////////
std::string describeFile (File& file)
{
std::stringstream out;
out << file._data
try
{
std::stringstream out;
out << file._data
<< " ("
<< (file.is_link ()
? 'l'
: (file.is_directory ()
? 'd'
: '-'))
? 'l'
: (file.is_directory ()
? 'd'
: '-'))
<< (file.readable ()
? 'r'
: '-')
? 'r'
: '-')
<< (file.writable ()
? 'w'
: '-')
? 'w'
: '-')
<< (file.executable ()
? 'x'
: '-')
? 'x'
: '-')
<< " " << file.size () << " bytes)";

return out.str ();
return out.str ();
}
catch (const std::string& error)
{
return file._data + " (" + error + ')';
}
catch (const std::exception& error)
{
return file._data + " (" + error.what () + ')';
}
catch (...)
{
return file._data + " (Unknown error)";
}
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 5 additions & 1 deletion src/commands/CmdReport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ int CmdReport (

// Run the extensions.
std::vector <std::string> output;
extensions.callExtension (script, split (input, '\n'), output);
int rc = extensions.callExtension (script, split (input, '\n'), output);
if (rc != 0 && output.size () == 0)
{
throw format ("'{1}' returned {2} without producing output.", script, rc);
}

// Display the output.
for (auto& line : output)
Expand Down

0 comments on commit d40cc91

Please sign in to comment.