Heart 1.3.842.34c2ab5
Heart is base back end library for your c++ Qt projects.
badrequest.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018-2024 QuasarApp.
3 * Distributed under the lgplv3 software license, see the accompanying
4 * Everyone is permitted to copy and distribute verbatim copies
5 * of this license document, but changing it is not allowed.
6*/
7
8#include "badrequest.h"
9
10#include <QDataStream>
11
12namespace QH{
13namespace PKG {
14
15
16BadRequest::BadRequest(unsigned char errocode, const QString &err) {
17 setErr(err);
18 setErrCode(errocode);
19}
20
22 BadRequest(data.code, data.msg) {
23}
24
26 BadRequest() {
27 fromBytes(package.data);
28}
29
30QDataStream &BadRequest::fromStream(QDataStream &stream) {
31 stream >> _errCode;
32 stream >> _err;
33
34 return stream;
35}
36
37QDataStream &BadRequest::toStream(QDataStream &stream) const {
38
39 stream << _errCode;
40 stream << _err;
41
42 return stream;
43}
44
45unsigned char BadRequest::errCode() const {
46 return _errCode;
47
48}
49
50void BadRequest::setErrCode(unsigned char code) {
51 _errCode = code;
52}
53
54QString BadRequest::err() const {
55 return _err;
56}
57
58void BadRequest::setErr(const QString &err) {
59 _err = err;
60}
61}
62}
The BadRequest class send response about error to client.
Definition badrequest.h:35
void setErrCode(unsigned char code)
setErrCode This method set error code.
QString err() const
err This method return a text of error message.
unsigned char errCode() const
errCode This method return code of error.
void setErr(const QString &err)
setErr - Set a error message.
QDataStream & fromStream(QDataStream &stream) override
fromStream This method should be read all bytes from the stream object and full the current object.
QDataStream & toStream(QDataStream &stream) const override
fromStream This method should be write all members of the current object to the stream object.
BadRequest(unsigned char errocode=ErrorCodes::InvalidRequest, const QString &err="")
BadRequest.
The Package struct. This is base structure for transporting data by network between QH nodes....
Definition package.h:23
QByteArray data
data This is source data of package.
Definition package.h:33
bool fromBytes(const QByteArray &data)
fromBytes This method provide initialization of object from byte array.
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
Definition heart.cpp:13
The ErrorData struct is simple structure for contains data of the error.
Definition badrequest.h:20