from flask import Blueprint

from . import v0

bp = Blueprint('api', __name__)
v0.api.init_app(bp)

def errorpage(e):
    code = getattr(e, 'code', 500)
    if code == 404:
        return jsonify(msg=str(e))
    return jsonify(msg="error", code=code)

from flask import Blueprint

from . import v0

bp = Blueprint('api', __name__)
v0.api.init_app(bp)

def errorpage(e):
    return v0.api.handle_error(e)

Improve error handling of sipa API
Improve error handling of sipa API

  from flask import Blueprint
  
  from . import v0
  
  bp = Blueprint('api', __name__)
  v0.api.init_app(bp)
  
  def errorpage(e):
+     return v0.api.handle_error(e)
-     code = getattr(e, 'code', 500)
-     if code == 404:
-         return jsonify(msg=str(e))
-     return jsonify(msg="error", code=code)
  
Improve error handling of sipa API
## Code Before:
from flask import Blueprint

from . import v0

bp = Blueprint('api', __name__)
v0.api.init_app(bp)

def errorpage(e):
    code = getattr(e, 'code', 500)
    if code == 404:
        return jsonify(msg=str(e))
    return jsonify(msg="error", code=code)

## Instruction:
Improve error handling of sipa API
## Code After:
from flask import Blueprint

from . import v0

bp = Blueprint('api', __name__)
v0.api.init_app(bp)

def errorpage(e):
    return v0.api.handle_error(e)
