mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Nicer failure check
This commit is contained in:
parent
46f5413b34
commit
f233cbd7f8
@ -140,7 +140,7 @@ document.title = 'compiler initialized';
|
|||||||
print('{}:{}:{}'.format(source_id, line_num, msg))
|
print('{}:{}:{}'.format(source_id, line_num, msg))
|
||||||
|
|
||||||
def __call__(self, src, options):
|
def __call__(self, src, options):
|
||||||
self.compiler_result = None
|
self.compiler_result = null = object()
|
||||||
self.errors = []
|
self.errors = []
|
||||||
self.working = True
|
self.working = True
|
||||||
options['basedir'] = '__stdlib__'
|
options['basedir'] = '__stdlib__'
|
||||||
@ -150,7 +150,7 @@ document.title = 'compiler initialized';
|
|||||||
self.runJavaScript(src, QWebEngineScript.ApplicationWorld, self.compilation_done)
|
self.runJavaScript(src, QWebEngineScript.ApplicationWorld, self.compilation_done)
|
||||||
while self.working:
|
while self.working:
|
||||||
self.spin_loop()
|
self.spin_loop()
|
||||||
if self.compiler_result is None:
|
if self.compiler_result is null:
|
||||||
raise CompileFailure('Failed to compile rapydscript code with error: ' + '\n'.join(self.errors))
|
raise CompileFailure('Failed to compile rapydscript code with error: ' + '\n'.join(self.errors))
|
||||||
write_cache = self.compiler_result[1]
|
write_cache = self.compiler_result[1]
|
||||||
with open(cache_path, 'wb') as f:
|
with open(cache_path, 'wb') as f:
|
||||||
@ -158,13 +158,13 @@ document.title = 'compiler initialized';
|
|||||||
return self.compiler_result[0]
|
return self.compiler_result[0]
|
||||||
|
|
||||||
def eval(self, js):
|
def eval(self, js):
|
||||||
self.compiler_result = None
|
self.compiler_result = null = object()
|
||||||
self.errors = []
|
self.errors = []
|
||||||
self.working = True
|
self.working = True
|
||||||
self.runJavaScript(js, QWebEngineScript.ApplicationWorld, self.compilation_done)
|
self.runJavaScript(js, QWebEngineScript.ApplicationWorld, self.compilation_done)
|
||||||
while self.working:
|
while self.working:
|
||||||
self.spin_loop()
|
self.spin_loop()
|
||||||
if self.compiler_result is None:
|
if self.compiler_result is null:
|
||||||
raise CompileFailure('Failed to eval JS with error: ' + '\n'.join(self.errors))
|
raise CompileFailure('Failed to eval JS with error: ' + '\n'.join(self.errors))
|
||||||
return self.compiler_result
|
return self.compiler_result
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user