mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 05:09:12 +00:00
LibRequests: Move NetworkError stringification to LibRequests
Let's also rename the file to NetworkError.h while we're here. No need to have "Enum" in the name.
This commit is contained in:
parent
a5df972055
commit
0de017df9b
Notes:
github-actions[bot]
2025-04-02 12:54:05 +00:00
Author: https://github.com/trflynn89
Commit: 0de017df9b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4156
7 changed files with 56 additions and 52 deletions
|
@ -1,5 +1,5 @@
|
|||
set(SOURCES
|
||||
NetworkErrorEnum.h
|
||||
NetworkError.h
|
||||
Request.cpp
|
||||
RequestClient.cpp
|
||||
WebSocket.cpp
|
||||
|
|
51
Libraries/LibRequests/NetworkError.h
Normal file
51
Libraries/LibRequests/NetworkError.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (c) 2024, the Ladybird developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/StringView.h>
|
||||
|
||||
namespace Requests {
|
||||
|
||||
enum class NetworkError {
|
||||
UnableToResolveProxy,
|
||||
UnableToResolveHost,
|
||||
UnableToConnect,
|
||||
TimeoutReached,
|
||||
TooManyRedirects,
|
||||
SSLHandshakeFailed,
|
||||
SSLVerificationFailed,
|
||||
MalformedUrl,
|
||||
Unknown
|
||||
};
|
||||
|
||||
constexpr StringView network_error_to_string(NetworkError network_error)
|
||||
{
|
||||
switch (network_error) {
|
||||
case NetworkError::UnableToResolveProxy:
|
||||
return "Unable to resolve proxy"sv;
|
||||
case NetworkError::UnableToResolveHost:
|
||||
return "Unable to resolve host"sv;
|
||||
case NetworkError::UnableToConnect:
|
||||
return "Unable to connect"sv;
|
||||
case NetworkError::TimeoutReached:
|
||||
return "Timeout reached"sv;
|
||||
case NetworkError::TooManyRedirects:
|
||||
return "Too many redirects"sv;
|
||||
case NetworkError::SSLHandshakeFailed:
|
||||
return "SSL handshake failed"sv;
|
||||
case NetworkError::SSLVerificationFailed:
|
||||
return "SSL verification failed"sv;
|
||||
case NetworkError::MalformedUrl:
|
||||
return "The URL is not formatted properly"sv;
|
||||
case NetworkError::Unknown:
|
||||
return "An unexpected network error occurred"sv;
|
||||
}
|
||||
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2024, the Ladybird developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Requests {
|
||||
|
||||
enum class NetworkError {
|
||||
UnableToResolveProxy,
|
||||
UnableToResolveHost,
|
||||
UnableToConnect,
|
||||
TimeoutReached,
|
||||
TooManyRedirects,
|
||||
SSLHandshakeFailed,
|
||||
SSLVerificationFailed,
|
||||
MalformedUrl,
|
||||
Unknown
|
||||
};
|
||||
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
#include <AK/WeakPtr.h>
|
||||
#include <LibCore/Notifier.h>
|
||||
#include <LibHTTP/HeaderMap.h>
|
||||
#include <LibRequests/NetworkErrorEnum.h>
|
||||
#include <LibRequests/NetworkError.h>
|
||||
#include <LibRequests/RequestTimingInfo.h>
|
||||
|
||||
namespace Requests {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue