aboutsummaryrefslogtreecommitdiffstats
path: root/messagebus/src/vespa/messagebus/routing/errordirective.h
blob: 895ac450e9b9527b88127f63bb704ac9fd6ff545 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "ihopdirective.h"

namespace mbus {

/**
 * This class represents an error directive within a {@link Hop}'s selector. This means to stop whatever is being
 * resolved, and instead return a reply containing a specified error.
 *
 * @author Simon Thoresen Hult
 * @version $Id$
 */
class ErrorDirective : public IHopDirective {
private:
    string _msg;

public:
    /**
     * Constructs a new error directive.
     *
     * @param msg The error message.
     */
    ErrorDirective(vespalib::stringref msg);
    ~ErrorDirective() override;

    /**
     * Returns the error string that is to be assigned to the reply.
     *
     * @return The error string.
     */
    const string &getMessage() const { return _msg; }

    Type getType() const override { return TYPE_ERROR; }
    bool matches(const IHopDirective &) const override { return false; }
    string toString() const override;
    string toDebugString() const override;
};

} // mbus