diff --git a/src/commands/CmdDiagnostics.cpp b/src/commands/CmdDiagnostics.cpp index 9ca1d55a..48ac1a49 100644 --- a/src/commands/CmdDiagnostics.cpp +++ b/src/commands/CmdDiagnostics.cpp @@ -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)"; + } } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/commands/CmdReport.cpp b/src/commands/CmdReport.cpp index 4ff79292..aed158b6 100644 --- a/src/commands/CmdReport.cpp +++ b/src/commands/CmdReport.cpp @@ -109,7 +109,11 @@ int CmdReport ( // Run the extensions. std::vector 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)