File: test_chaining.py

package info (click to toggle)
python-better-exceptions 0.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 632 kB
  • sloc: python: 620; sh: 108; makefile: 5
file content (21 lines) | stat: -rw-r--r-- 348 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# -*- coding:utf-8 -*-

import better_exceptions
better_exceptions.hook()

def div(x, y):
    x / y

def cause(x, y):
    try:
        div(x, y)
    except Exception:
        raise ValueError("Division error")

def context(x, y):
    try:
        cause(x, y)
    except Exception as e:
        raise ValueError("Cause error") from e

context(1, 0)