# FickleServiceError

**URL:** <https://users.rust-lang.org/t/fickleserviceerror/100489>\
**Category:** uncategorized\
**Created:** [September 27, 2023, 3:57pm UTC](https://users.rust-lang.org/t/fickleserviceerror/100489 "2023-09-27T15:57:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![arifd](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/arifd/32/17291_2.png) [@arifd](https://users.rust-lang.org/u/arifd)\
**Post date:** [September 27, 2023, 3:57pm UTC](https://users.rust-lang.org/t/fickleserviceerror/100489/1 "2023-09-27T15:57:43Z")

</div>

I have decided to go distributed, and now I have welcomed unto myself the woes of distributed. 😕

One problem I am having is that my code has no (explicit) concept of a service that can fail due to being temporarily unavailable. it does many things, and makes use of `?` a lot. when the error is bubbled up to its final location, I need something that lets my code know that it can "attempt this task again", it should not do the standard "log error and give up 🤷‍♂️". But my code interfaces with many other crates in my workspace. So I was wondering...

Could I maybe make some kind of:

```rust
pub enum FickleError {
    TryAgain,
    Other(Box<dyn Error),
}

```

and have my function in question return a `Result<T, impl Into<FickleError>>` so that I demand that the crates upstream (in my workspace) impl `Into<FickleError>` for their errors so that they help me understand when I can possibly try again.

---

<div class="post-metadata">

**Author:** ![kpreid](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/kpreid/32/22420_2.png) [@kpreid](https://users.rust-lang.org/u/kpreid)\
**Post date:** [September 27, 2023, 4:19pm UTC](https://users.rust-lang.org/t/fickleserviceerror/100489/2 "2023-09-27T16:19:44Z")

</div>

Two things:

1. To achieve your specific plan, it would probably be better to add a _trait_ that errors implement:

2. You will probably find that it isn't easy to classify errors as retriable or not. Particularly, in a complex system, there are many errors that may be _consequences of something being overloaded,_ but aren't inherently about that.

I am glad to see that you say "when the error is bubbled up to its final location". Nested retry policies can result in hiding problems and creating excessive latency. Remember that the real “final location” isn't necessarily in the same server.

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/system/32/51372_2.png) [@system](https://users.rust-lang.org/u/system)\
**Post date:** [December 26, 2023, 4:19pm UTC](https://users.rust-lang.org/t/fickleserviceerror/100489/3 "2023-12-26T16:19:49Z")

</div>

Closed on December 26, 2023, 4:19pm UTC

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.
