Permalink
Browse files

Improve error output when there is a problem starting PHP.

Summary:
Improve error output when there is a problem starting PHP.
  • Loading branch information...
1 parent b9ab98c commit 6c749f745e5eadc1874f6923aa18efdde8f7b6dd Aran Donohue committed with adonohue Jul 28, 2010
Showing with 22 additions and 4 deletions.
  1. +22 −4 src/__init__.py
View
@@ -229,9 +229,15 @@ def clear(self):
self.partial = ""
class ProblemStartingPhp(Exception):
- def __init__(self, file_name = None, line_num = None):
+ def __init__(self,
+ file_name=None,
+ line_num=None,
+ stdout_lines=None,
+ stderr_lines=None):
self.file_name = file_name
self.line_num = line_num
+ self.stdout_lines = stdout_lines
+ self.stderr_lines = stderr_lines
class PhpshConfig:
def __init__(self):
@@ -614,6 +620,13 @@ def php_open_and_check(self):
phpsh failed to initialize PHP.
Fix the problem and hit enter to reload or ctrl-C to quit.""")
+ if e.stdout_lines:
+ print("PHP output: %(output)s" %
+ {'output' : "\n".join(e.stdout_lines)})
+ if e.stderr_lines:
+ print("PHP error output: %(output)s" %
+ {'output' : "\n".join(e.stderr_lines)})
+
if e.line_num:
print("\
Type 'e' to open emacs or 'V' to open vim to %s: %s" %
@@ -666,7 +679,8 @@ def php_open(self):
p_line = self.p.stdout.readline().rstrip()
if p_line != "#start_autocomplete_identifiers":
- err_lines = self.p.stderr.readlines();
+ err_lines = self.p.stderr.readlines()
+ out_lines = self.p.stdout.readlines()
err_str = "\
UNKNOWN ERROR (maybe php build does not support signals/tokenizer?)"
@@ -687,9 +701,13 @@ def php_open(self):
if m:
file_name, line_num = m.groups()
- raise ProblemStartingPhp(file_name, line_num)
+ raise ProblemStartingPhp(file_name,
+ line_num,
+ stdout_lines=out_lines,
+ stderr_lines=err_lines)
else:
- raise ProblemStartingPhp()
+ raise ProblemStartingPhp(stdout_lines=out_lines,
+ stderr_lines=err_lines)
while True:
p_line = self.p.stdout.readline().rstrip()

0 comments on commit 6c749f7

Please sign in to comment.