errorHandling.rst (cheetah3-3.1.0) | : | errorHandling.rst (cheetah3-3.2.0) | ||
---|---|---|---|---|
Directives: Error Handling | Directives: Error Handling | |||
========================== | ========================== | |||
(errorHandling) | ||||
#try and #raise | #try and #raise | |||
--------------- | --------------- | |||
(errorHandling.try) | ||||
The template: | The template: | |||
:: | :: | |||
#import traceback | #import traceback | |||
#try | #try | |||
#raise RuntimeError | #raise RuntimeError | |||
#except RuntimeError | #except RuntimeError | |||
A runtime error occurred. | A runtime error occurred. | |||
#end try | #end try | |||
skipping to change at line 70 | skipping to change at line 66 | |||
write(filter(1/0)) | write(filter(1/0)) | |||
write('\n') | write('\n') | |||
except ZeroDivisionError: | except ZeroDivisionError: | |||
write("You can't divide by zero, idiot!\n") | write("You can't divide by zero, idiot!\n") | |||
{#finally} works just like in Python. | {#finally} works just like in Python. | |||
#assert | #assert | |||
------- | ------- | |||
(errorHandling.assert) | ||||
The template: | The template: | |||
:: | :: | |||
#assert False, "You lose, buster!" | #assert False, "You lose, buster!" | |||
The output: | The output: | |||
:: | :: | |||
skipping to change at line 104 | skipping to change at line 98 | |||
The generated code: | The generated code: | |||
:: | :: | |||
assert False, "You lose, buster!" | assert False, "You lose, buster!" | |||
#errorCatcher | #errorCatcher | |||
------------- | ------------- | |||
(errorHandling.errorCatcher) | ||||
No error catcher | No error catcher | |||
~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~ | |||
(errorHandling.errorCatcher.no) | ||||
The template: | The template: | |||
:: | :: | |||
$noValue | $noValue | |||
The output: | The output: | |||
:: | :: | |||
skipping to change at line 146 | skipping to change at line 136 | |||
:: | :: | |||
write(filter(VFS(SL,"noValue",1))) # generated from '$noValue' at line 1, | write(filter(VFS(SL,"noValue",1))) # generated from '$noValue' at line 1, | |||
# col 1. | # col 1. | |||
write('\n') | write('\n') | |||
Echo and BigEcho | Echo and BigEcho | |||
~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~ | |||
(errorHandling.errorCatcher.echo) | ||||
The template: | The template: | |||
:: | :: | |||
#errorCatcher Echo | #errorCatcher Echo | |||
$noValue | $noValue | |||
#errorCatcher BigEcho | #errorCatcher BigEcho | |||
$noValue | $noValue | |||
The output: | The output: | |||
skipping to change at line 187 | skipping to change at line 175 | |||
else: | else: | |||
self._errorCatcher = self._errorCatchers["BigEcho"] = \ | self._errorCatcher = self._errorCatchers["BigEcho"] = \ | |||
ErrorCatchers.BigEcho(self) | ErrorCatchers.BigEcho(self) | |||
write(filter(self.__errorCatcher1(localsDict=locals()))) | write(filter(self.__errorCatcher1(localsDict=locals()))) | |||
# generated from '$noValue' at line 4, col 1. | # generated from '$noValue' at line 4, col 1. | |||
write('\n') | write('\n') | |||
ListErrors | ListErrors | |||
~~~~~~~~~~ | ~~~~~~~~~~ | |||
(errorHandling.errorCatcher.listErrors) | ||||
The template: | The template: | |||
:: | :: | |||
#import pprint | #import pprint | |||
#errorCatcher ListErrors | #errorCatcher ListErrors | |||
$noValue | $noValue | |||
$anotherMissingValue.really | $anotherMissingValue.really | |||
$pprint.pformat($errorCatcher.listErrors) | $pprint.pformat($errorCatcher.listErrors) | |||
## This is really self.errorCatcher().listErrors() | ## This is really self.errorCatcher().listErrors() | |||
End of changes. 7 change blocks. | ||||
14 lines changed or deleted | 0 lines changed or added |