#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import logging

# try
try:
    print('try...')
    r = 10 / 0
    print('result:', r)
except ZeroDivisionError as e:
    print('except:', e)
finally:
    print('finally...')

# error
def foo(s):
    return 10 / int(s)

def bar(s):
    return foo(s) * 2

def main():
    try:
        bar('0')
    except Exception as e:
        logging.exception(e)

main()
print('END')

class FooError(ValueError):
    pass

def foos(s):
    n = int(s)
    if n == 0:
        raise FooError('invalid value: %s', s)
        return 10 / n
    
foos('0')