Skip to content

Commit

Permalink
net: define a generic parsing exception
Browse files Browse the repository at this point in the history
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
  • Loading branch information
dotnwat committed Apr 12, 2024
1 parent b13c005 commit 42f826c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/v/net/connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include "base/seastarx.h"
#include "net/exceptions.h"
#include "rpc/service.h"
#include "net/types.h"
#include "ssx/abort_source.h"

#include <seastar/core/future.hh>
Expand Down Expand Up @@ -85,7 +85,7 @@ std::optional<ss::sstring> is_disconnect_exception(std::exception_ptr e) {
// Happens on unclean client disconnect, when io_iterator_consumer
// gets fewer bytes than it wanted
return "short read";
} catch (const rpc::rpc_internal_body_parsing_exception&) {
} catch (const net::parsing_exception&) {
// Happens on unclean client disconnect, typically wrapping
// an out_of_range
return "parse error";
Expand Down
2 changes: 2 additions & 0 deletions src/v/net/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ class authentication_exception : public std::runtime_error {
: std::runtime_error(m) {}
};

class parsing_exception : public std::exception {};

} // namespace net
3 changes: 2 additions & 1 deletion src/v/rpc/service.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#pragma once

#include "base/seastarx.h"
#include "net/types.h"
#include "reflection/async_adl.h"
#include "rpc/parse_utils.h"
#include "rpc/types.h"
Expand Down Expand Up @@ -39,7 +40,7 @@ struct service {
virtual void setup_metrics() = 0;
};

class rpc_internal_body_parsing_exception : public std::exception {
class rpc_internal_body_parsing_exception : public net::parsing_exception {
public:
explicit rpc_internal_body_parsing_exception(const std::exception_ptr& e)
: _what(
Expand Down

0 comments on commit 42f826c

Please sign in to comment.