1 /*
2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2017 Vladimir Golovnev <glassez@yandex.ru>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 * In addition, as a special exception, the copyright holders give permission to
20 * link this program with the OpenSSL project's "OpenSSL" library (or with
21 * modified versions of it that use the same license as the "OpenSSL" library),
22 * and distribute the linked executables. You must obey the GNU General Public
23 * License in all respects for all of the code used other than "OpenSSL". If you
24 * modify file(s), you may extend this exception to your version of the file(s),
25 * but you are not obligated to do so. If you do not wish to do so, delete this
26 * exception statement from your version.
27 */
28
29 #include "httperror.h"
30
HTTPError(const int statusCode,const QString & statusText,const QString & message)31 HTTPError::HTTPError(const int statusCode, const QString &statusText, const QString &message)
32 : RuntimeError {message}
33 , m_statusCode {statusCode}
34 , m_statusText {statusText}
35 {
36 }
37
statusCode() const38 int HTTPError::statusCode() const
39 {
40 return m_statusCode;
41 }
42
statusText() const43 QString HTTPError::statusText() const
44 {
45 return m_statusText;
46 }
47
BadRequestHTTPError(const QString & message)48 BadRequestHTTPError::BadRequestHTTPError(const QString &message)
49 : HTTPError(400, QLatin1String("Bad Request"), message)
50 {
51 }
52
UnauthorizedHTTPError(const QString & message)53 UnauthorizedHTTPError::UnauthorizedHTTPError(const QString &message)
54 : HTTPError(401, QLatin1String("Unauthorized"), message)
55 {
56 }
57
ForbiddenHTTPError(const QString & message)58 ForbiddenHTTPError::ForbiddenHTTPError(const QString &message)
59 : HTTPError(403, QLatin1String("Forbidden"), message)
60 {
61 }
62
NotFoundHTTPError(const QString & message)63 NotFoundHTTPError::NotFoundHTTPError(const QString &message)
64 : HTTPError(404, QLatin1String("Not Found"), message)
65 {
66 }
67
MethodNotAllowedHTTPError(const QString & message)68 MethodNotAllowedHTTPError::MethodNotAllowedHTTPError(const QString &message)
69 : HTTPError(405, QLatin1String("Method Not Allowed"), message)
70 {
71 }
72
ConflictHTTPError(const QString & message)73 ConflictHTTPError::ConflictHTTPError(const QString &message)
74 : HTTPError(409, QLatin1String("Conflict"), message)
75 {
76 }
77
UnsupportedMediaTypeHTTPError(const QString & message)78 UnsupportedMediaTypeHTTPError::UnsupportedMediaTypeHTTPError(const QString &message)
79 : HTTPError(415, QLatin1String("Unsupported Media Type"), message)
80 {
81 }
82
InternalServerErrorHTTPError(const QString & message)83 InternalServerErrorHTTPError::InternalServerErrorHTTPError(const QString &message)
84 : HTTPError(500, QLatin1String("Internal Server Error"), message)
85 {
86 }
87