Skip to content

Improving error messages when we cannot deconvert a type.#366

Merged
slawlor merged 1 commit intoslawlor:mainfrom
krisajenkins:main
Jul 23, 2025
Merged

Improving error messages when we cannot deconvert a type.#366
slawlor merged 1 commit intoslawlor:mainfrom
krisajenkins:main

Conversation

@krisajenkins
Copy link
Contributor

When you send a message to a DerivedActor, we convert the message to the receiver's type. If the message sending fails, we deconvert it to show you which message failed. However, if the deconversion fails, you get a very terse error message:

PANIC: Failed to deconvert message to from type

Obviously that provides very little diagnostic information. This change greatly improves the error to something like:

PANIC: Failed to deconvert message from klite::queries::query_watcher::QueryWatcherMessage to klite::connection_manager::ClientResponse when sending back to: Actor { name: Some("current_subscribers.sql"), id: Local(8) }

Now you know exactly which kind of message was sent to whom, and which TryFrom instance you need to fix.

(NOTE: These errors should be very rare. TryFrom should be implemented properly. But when very rare errors happen that's exactly when you need very good error messages.)

@slawlor
Copy link
Owner

slawlor commented Jul 15, 2025

can you run clippy and update the PR? Thanks!

@codecov
Copy link

codecov bot commented Jul 15, 2025

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@7f12788). Learn more about missing BASE report.

Files with missing lines Patch % Lines
ractor/src/actor/derived_actor.rs 0.00% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #366   +/-   ##
=======================================
  Coverage        ?   82.28%           
=======================================
  Files           ?       70           
  Lines           ?    12765           
  Branches        ?        0           
=======================================
  Hits            ?    10504           
  Misses          ?     2261           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@krisajenkins
Copy link
Contributor Author

I've just taken a look at the clippy warnings, and it doesn't look like they're related to this change. They're about using the newer-style inline variable names in format strings:

error: variables can be used directly in the `format!` string
Error:    --> ractor/src/errors.rs:243:31
    |
243 |             Self::Spawn(s) => write!(f, "Spawn({:?})", s),
    |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^

I can fix those if you'd like, but it might belong in a different PR?

@slawlor
Copy link
Owner

slawlor commented Jul 22, 2025

Yeah please just lint the whole project. It's the typical flow even if it is touching some other code to keep the lib up to date. Thanks!

When you send a message to a `DerivedActor`, we convert the message to
the receiver's type. If the message sending fails, we deconvert it to
show you which message failed. However, if the deconversion fails, you
get a very terse error message:

```log
PANIC: Failed to deconvert message to from type
```

Obviously that provides very little diagnostic information. This change
greatly improves the error to something like:

```log
PANIC: Failed to deconvert message from klite::queries::query_watcher::QueryWatcherMessage to klite::connection_manager::ClientResponse when sending back to: Actor { name: Some("current_subscribers.sql"), id: Local(8) }
```

Now you know exactly which kind of message was sent to whom, and which
`TryFrom` instance you need to fix.

(NOTE: These errors should be very rare. `TryFrom` _should_ be
implemented properly. But when very rare errors happen that's exactly
when you need very good error messages.)
@slawlor slawlor merged commit 7d84406 into slawlor:main Jul 23, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants