]> granicus.if.org Git - icinga2/commitdiff
Fix incorrect source line info in the CLI console
authorGunnar Beutner <gunnar@beutner.name>
Fri, 16 Jan 2015 09:07:11 +0000 (10:07 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Fri, 16 Jan 2015 09:07:11 +0000 (10:07 +0100)
fixes #8240

lib/cli/consolecommand.cpp

index a94c14e9afd366d830a9a7c44264a043ab34a53f..fd134bb8827ec7b9171531add9bf01ef4e071d8b 100644 (file)
@@ -109,9 +109,13 @@ int ConsoleCommand::Run(const po::variables_map& vm, const std::vector<std::stri
                        } catch (const ScriptError& ex) {
                                DebugInfo di = ex.GetDebugInfo();
 
-                               std::cout << di.Path << ": " << lines[di.Path] << "\n";
-                               std::cout << String(di.Path.GetLength() + 2, ' ');
-                               std::cout << String(di.FirstColumn, ' ') << String(di.LastColumn - di.FirstColumn + 1, '^') << "\n";
+                               if (lines.find(di.Path) != lines.end()) {
+                                       std::cout << di.Path << ": " << lines[di.Path] << "\n";
+                                       std::cout << String(di.Path.GetLength() + 2, ' ');
+                                       std::cout << String(di.FirstColumn, ' ') << String(di.LastColumn - di.FirstColumn + 1, '^') << "\n";
+                               } else {
+                                       ShowCodeFragment(std::cout, di);
+                               }
 
                                std::cout << ex.what() << "\n";
                        } catch (const std::exception& ex) {