Skip to content

Commit dae12c9

Browse files
committed
event/net/ConnectSocket: use class TimeoutError in OnSocketConnectTimeout()
1 parent 92d769b commit dae12c9

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/event/net/ConnectSocket.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "net/SocketAddress.hxx"
88
#include "net/AddressInfo.hxx"
99
#include "net/SocketError.hxx"
10+
#include "net/TimeoutError.hxx"
1011

1112
#include <cassert>
1213
#include <stdexcept>
@@ -15,7 +16,7 @@ void
1516
ConnectSocketHandler::OnSocketConnectTimeout() noexcept
1617
{
1718
/* default implementation falls back to OnSocketConnectError() */
18-
OnSocketConnectError(std::make_exception_ptr(std::runtime_error("Connect timeout")));
19+
OnSocketConnectError(std::make_exception_ptr(TimeoutError{"Connect timeout"}));
1920
}
2021

2122
ConnectSocket::ConnectSocket(EventLoop &_event_loop,

src/net/TimeoutError.hxx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// SPDX-License-Identifier: BSD-2-Clause
2+
// Copyright CM4all GmbH
3+
// author: Max Kellermann <[email protected]>
4+
5+
#pragma once
6+
7+
#include <stdexcept>
8+
9+
/**
10+
* Some operation has timed out (e.g. connecting to a server, waiting
11+
* for reply from a server).
12+
*/
13+
class TimeoutError : public std::runtime_error {
14+
public:
15+
using std::runtime_error::runtime_error;
16+
17+
TimeoutError() noexcept
18+
:std::runtime_error("Timeout") {}
19+
};

0 commit comments

Comments
 (0)