コード例 #1
0
    def get(self, user_id):
        """Get a single user details"""
        try:
            user = User.get(hash_key=user_id)
            if user is None:
                app.logger.error('ERROR:user_id not exist:{}'.format(user_id))
                return err_response({'user_id': user_id}, 404)

            data = {
                'user': {
                    'id': user.id,
                    'username': user.username,
                    'email': user.email
                }
            }
            app.logger.debug("success:user_get_by_id:%s" % data['user'])
            return m_response(data, 200)
        except ValueError as e:
            app.logger.error("ERROR:user_get_by_id:{}".format(user_id))
            app.logger.error(e)
            return err_response("ERROR:user_get_by_id:{}".format(user_id), 500)
        except Exception as e:
            app.logger.error("ERROR:user_get_by_id:{}".format(user_id))
            app.logger.error(e)
            return err_response("ERROR:user_get_by_id:{}".format(user_id), 500)
コード例 #2
0
    def get(self, user_id):
        """Get a single user details"""
        try:
            user = User.get(hash_key=user_id)
            if user is None:
                app.logger.error('ERROR:user_id not exist:{}'.format(user_id))
                raise BadRequest('User not exist')

            user = {
                'id': user.id,
                'username': user.username,
                'email': user.email
            }
            app.logger.debug('success:user_get_by_id: {0}'.format(user))
            return make_response({'ok': True, 'users': user}, 200)
        except ValueError as e:
            app.logger.error('user_get_by_id:{0}, {1}'.format(user_id, e))
            raise BadRequest(e)
        except Exception as e:
            app.logger.error('Unexpected Error: {0}, {1}'.format(user_id, e))
            raise InternalServerError('Unexpected Error:{0}'.format(e))