Skip to content

Commit

Permalink
New error code: Offline
Browse files Browse the repository at this point in the history
Used to indicate absence of network connectivity

Relates-To: OCMAM-420
Signed-off-by: Andrey Kashcheev <[email protected]>
  • Loading branch information
andrey-kashcheev committed Feb 6, 2025
1 parent 0006cd2 commit 1bfe7b2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
14 changes: 13 additions & 1 deletion olp-cpp-sdk-core/include/olp/core/client/ApiError.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2024 HERE Europe B.V.
* Copyright (C) 2019-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -109,6 +109,18 @@ class CORE_API ApiError {
return {ErrorCode::CacheIO, description};
}

/**
* @brief Creates the `ApiError` instance with the offline error code and
* description.
*
* @param description The optional description.
*
* @return The `ApiError` instance.
*/
static ApiError Offline(const char* description = "Offline") {
return {ErrorCode::Offline, description};
}

/**
* @brief Creates the `ApiError` instance with the unknown error code and
* description.
Expand Down
7 changes: 6 additions & 1 deletion olp-cpp-sdk-core/include/olp/core/client/ErrorCode.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2024 HERE Europe B.V.
* Copyright (C) 2019-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -96,6 +96,11 @@ enum class ErrorCode {
* The device is full and cannot store more data.
*/
NoSpaceLeft,

/**
* Absence of network connectivity.
*/
Offline,
};

} // namespace client
Expand Down
3 changes: 2 additions & 1 deletion olp-cpp-sdk-core/include/olp/core/http/HttpStatusCode.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2021 HERE Europe B.V.
* Copyright (C) 2019-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -154,6 +154,7 @@ class CORE_API HttpStatusCode {
if (http_code < 0) {
switch (static_cast<olp::http::ErrorCode>(http_code)) {
case olp::http::ErrorCode::OFFLINE_ERROR:
return olp::client::ErrorCode::Offline;
case olp::http::ErrorCode::IO_ERROR:
return olp::client::ErrorCode::NetworkConnection;
case olp::http::ErrorCode::TIMEOUT_ERROR:
Expand Down

0 comments on commit 1bfe7b2

Please sign in to comment.