Skip to content

New error code: Offline #1585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading