api.v1_0.bad_request_error()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
from flask import Blueprint, g
2
from ..errors import ValidationError, bad_request, not_found
3
4
5
api = Blueprint('api', __name__)
6
7
8
@api.errorhandler(ValidationError)
9
def validation_error(e):
10
  return bad_request(e.args[0])
11
12
13
@api.errorhandler(400)
14
def bad_request_error(e):
15
  return bad_request('invalid request')
16
17
18
@api.errorhandler(404)
19
def not_found_error(e):
20
  return not_found('item not found')
21
22
23
@api.after_request
24
def after_request(response):
25
  if hasattr(g, 'headers'):
26
    response.headers.extend(g.headers)
27
  return response
28
29
# do this last to avoid circular dependencies
30
from . import todos
31