开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (6)
master
feature/48-mysql-connection-pool
gh-pages
bugfix/52-volume-already-in-use
feature/6-simplify-deployment
async-rewrite
master
分支 (6)
master
feature/48-mysql-connection-pool
gh-pages
bugfix/52-volume-already-in-use
feature/6-simplify-deployment
async-rewrite
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (6)
master
feature/48-mysql-connection-pool
gh-pages
bugfix/52-volume-already-in-use
feature/6-simplify-deployment
async-rewrite
error.hpp 3.99 KB
一键复制 编辑 原始数据 按行查看 历史
Ruben Perez 提交于 2023年09月26日 23:21 +08:00 . Authentication, login and account creation
//
// Copyright (c) 2023 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef SERVERTECHCHAT_SERVER_INCLUDE_ERROR_HPP
#define SERVERTECHCHAT_SERVER_INCLUDE_ERROR_HPP
#include <boost/assert/source_location.hpp>
#include <boost/system/error_category.hpp>
#include <boost/system/error_code.hpp>
#include <boost/system/result.hpp>
#include <string>
#include <string_view>
#include <utility>
// Error management infrastructure. Uses Boost.System error codes and categories.
// This is consistent with Asio, Beast and Redis.
namespace chat {
// Type alias to reduce verbosity.
using error_code = boost::system::error_code;
// Type alias to reduce verbosity.
template <class T>
using result = boost::system::result<T>;
// An error code with a diagnostics message
struct error_with_message
{
error_code ec;
std::string msg;
};
// Required by the Boost.System infrastructure.
// Throws an exception from an error_with_message.
[[noreturn]] void throw_exception_from_error(const error_with_message& e, const boost::source_location&);
// Like result, but the error state includes an error message
template <class T>
using result_with_message = boost::system::result<T, error_with_message>;
// Error code enum for errors originated within our application
enum class errc
{
redis_parse_error = 1, // Data retrieved from Redis didn't match the format we expected
redis_command_failed, // A Redis command failed execution (e.g. we provided the wrong number of args)
websocket_parse_error, // Data received from the client didn't match the format we expected
username_exists, // couldn't create user, duplicate username
email_exists, // couldn't create user, duplicate username
not_found, // couldn't retrieve a certain resource, it doesn't exist
invalid_password_hash, // we found a password hash that was malformed
already_exists, // an entity can't be created because it already exists
requires_auth, // the requested resource requires authentication, but credentials haven't been provided
// or are invalid
invalid_base64, // attempt to decode an invalid base64 string
uncaught_exception, // an API handler threw an unexpected exception
invalid_content_type, // an endpoint received an unsupported Content-Type
};
// The error category for errc
const boost::system::error_category& get_chat_category() noexcept;
// Allows constructing error_code from errc
inline error_code make_error_code(errc v) noexcept
{
return error_code(static_cast<int>(v), get_chat_category());
}
// Logs ec to stderr
void log_error(error_code ec, std::string_view what, std::string_view diagnostics = "");
inline void log_error(const error_with_message& err, std::string_view what)
{
log_error(err.ec, what, err.msg);
}
} // namespace chat
// Allows constructing error_code from errc
namespace boost {
namespace system {
template <>
struct is_error_code_enum<chat::errc>
{
static constexpr bool value = true;
};
} // namespace system
} // namespace boost
// Returns an error_code with source-code location information on it
#define CHAT_RETURN_ERROR(e) \
{ \
static constexpr auto loc = BOOST_CURRENT_LOCATION; \
return ::chat::error_code(::chat::error_code(e), &loc); \
}
// Returns an error_with_message with source-code location information on the error_code
#define CHAT_RETURN_ERROR_WITH_MESSAGE(e, msg) \
{ \
static constexpr auto loc = BOOST_CURRENT_LOCATION; \
return ::chat::error_with_message{::chat::error_code(::chat::error_code(e), &loc), msg}; \
}
#endif
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

Web聊天室项目
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cppprojects/servertech-chat.git
git@gitee.com:cppprojects/servertech-chat.git
cppprojects
servertech-chat
servertech-chat
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /