Skip to content

Commit f8389f3

Browse files
Merge pull request #2 from FrontierDevelopmentLab/improvements-readme-and-rough-edges
Improvements readme and rough edges
2 parents c4ccf9c + ead0fa2 commit f8389f3

4 files changed

Lines changed: 16 additions & 7 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# eve-api
22

3+
[![CI](https://github.com/FrontierDevelopmentLab/eve-api/actions/workflows/main.yml/badge.svg)](https://github.com/FrontierDevelopmentLab/eve-api/actions/workflows/main.yml)
4+
[![Python](https://img.shields.io/badge/python-3.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue)](https://github.com/FrontierDevelopmentLab/eve-api)
5+
[![License: MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE)
6+
37
Minimal authenticated HTTP client for the EVE (Earth Virtual Expert) API.
48

59
Provides login, automatic JWT token refresh, and generic HTTP methods that return plain dicts. No domain-specific wrappers or Pydantic models.

src/eve_api/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def _handle_error(response: httpx.Response) -> None:
356356
message = response.text or f"HTTP {status}"
357357

358358
if status == HTTPStatus.NOT_FOUND:
359-
raise NotFoundError("resource", "unknown")
359+
raise NotFoundError(message)
360360
if status == HTTPStatus.FORBIDDEN:
361361
raise ForbiddenError(message)
362362
if status == HTTPStatus.BAD_REQUEST:

src/eve_api/exceptions.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,22 @@ def __init__(
5858
class NotFoundError(APIError):
5959
"""Raised when a requested resource is not found (404)."""
6060

61-
def __init__(self, resource: str, resource_id: str) -> None:
61+
def __init__(
62+
self,
63+
message: str = "Resource not found",
64+
details: dict[str, Any] | None = None,
65+
) -> None:
6266
"""Initialise the not found error.
6367
6468
Args:
65-
resource: Type of resource (e.g., 'conversation', 'document').
66-
resource_id: ID of the resource that was not found.
69+
message: Human-readable error message (typically the server's
70+
``detail`` field).
71+
details: Additional error details from the response body.
6772
"""
6873
super().__init__(
69-
f"{resource.title()} not found: {resource_id}",
74+
message,
7075
status_code=HTTPStatus.NOT_FOUND,
71-
details={"resource": resource, "id": resource_id},
76+
details=details,
7277
)
7378

7479

tests/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ async def test_404_raises_not_found(mock_api, authenticated_client: EVEClient):
236236
)
237237
)
238238

239-
with pytest.raises(NotFoundError) as exc_info:
239+
with pytest.raises(NotFoundError, match="Not found") as exc_info:
240240
await authenticated_client.get("/conversations/missing")
241241

242242
assert exc_info.value.status_code == HTTPStatus.NOT_FOUND

0 commit comments

Comments
 (0)