def safe_int(value):
try:<EOL><INDENT>result = int(value)<EOL>if result < <NUM_LIT:0>:<EOL><INDENT>raise NegativeDurationError(<EOL>'<STR_LIT>'<EOL>)<EOL><DEDENT><DEDENT>except NegativeDurationError as exc:<EOL><INDENT>raise exc<EOL><DEDENT>except (TypeError, ValueError):<EOL><INDENT>result = <NUM_LIT:0><EOL><DEDENT>return result<EOL>
Tries to convert a value to int; returns 0 if conversion failed