Commit Graph

2334 Commits

Author SHA1 Message Date
Nick Mathewson 3c342ae5d7 Add TODOs on uncertain points about time_since_last_traffic
This edge-case was there even before the migration of
595fe1ab88, but now it's more explicit and ought to be
revisited.
2022-02-09 10:06:53 -05:00
Nick Mathewson e8244c3389 Merge branch 'issue-324' into 'main'
Remove the use of Mutex in channel unused_since timestamp

See merge request tpo/core/arti!293
2022-02-09 15:03:48 +00:00
eta 1e7013848c Merge branch 'allow-failure-coverage' into 'main'
Temporarily allow failures in the coverage CI.

See merge request tpo/core/arti!295
2022-02-09 14:08:06 +00:00
Nick Mathewson e7a38ccb55 Temporarily allow failures in the coverage CI.
Right now it's failing on nightly through no fault of our own.
2022-02-09 08:29:00 -05:00
Yuan Lyu 595fe1ab88 Remove the use of Mutex in channel unused_since timestamp 2022-02-08 18:28:45 -05:00
eta ba2eb765f5 Merge branch 'error_improvements2' into 'main'
Another set of improvements to the error code

Closes #321

See merge request tpo/core/arti!294
2022-02-08 23:21:23 +00:00
Nick Mathewson ff33faf984 Update launch of chan expiration task to new API
This fixes a compilation error.
2022-02-08 10:41:14 -05:00
Nick Mathewson 3f39737817 ErrorDetail Simplify visibility macros a bit.
Instead of declaring a macro that takes vis as an argument, we now
conditionally declare a macro that applies an appropriate visibility.

There's a long comment explaining the rationale here, along with a
couple of other solutions that don't work.
2022-02-08 10:37:46 -05:00
Nick Mathewson d00f00dd41 Rename TorResult to Result.
This is closer to common usage.

(Not that we all agree with common usage, but it's closer to what
people expect.)
2022-02-08 10:37:46 -05:00
Nick Mathewson 80716a294b arti_client: Rename Error to ErrorDetail.
This is closer to what we described in Errors.md.

Also, remove the (sometimes private) Result alias: it was only used in
one or two places, and never exposed in public.
2022-02-08 10:37:46 -05:00
Nick Mathewson 929bcc6c86 TorError: Make detail() an accessor function.
This change lets us make TorError's members unconditionally hidden,
and makes our API a little more consistent (since basically nothing
else is a public field).
2022-02-08 10:37:46 -05:00
eta 109515ecfe Merge branch 'error-improvements' into 'main'
Hopefully uncontroversial improvements to new Error code

See merge request tpo/core/arti!291
2022-02-08 14:42:30 +00:00
Nick Mathewson 1dbb23982f Merge branch 'issue-41' into 'main'
Expire channels that have been unused for too long

See merge request tpo/core/arti!273
2022-02-07 15:39:52 +00:00
Yuan Lyu 3552a49652 Clean up ChannelState ready_to_expire 2022-02-06 15:25:52 -05:00
Yuan Lyu f6f732a478 Expire channels that have been unused for too long 2022-02-04 22:52:51 -05:00
Nick Mathewson f08c0268bc Tests for TargetPorts::display() 2022-02-04 16:41:32 -05:00
Nick Mathewson c43f494b44 tests for tor-error::internal
These tests turned up a need for using the #[track_caller]
annotation in order to get accurate locations, which is fortunately
stable since Rust 1.46.0.
2022-02-04 16:33:43 -05:00
Nick Mathewson 1166977975 Docs and clarification for a bunch of Error stuff 2022-02-04 16:06:11 -05:00
Nick Mathewson 070e52653d Make SpawnError wrappers contain a 'spawning' string
(By our convention, these errors should say what we were trying to
spawn when the error occurred.)
2022-02-04 16:06:11 -05:00
Nick Mathewson 9bd7419c20 Make the Error detail type non-exported from arti-client
At least by default, we should have Error be private, and not expose
it as part of our APIs.

To keep functionality in `arti`, I had to add an `ExitTimeout` error
kind.

For interface consistency, I also re-exported ErrorKind and HasError
from `arti_client`.
2022-02-04 16:06:11 -05:00
Nick Mathewson 7462971c1b Test that TorError implements the right traits.
I had planned to use assert_impl, but that can't check for
the 'static lifetime.
2022-02-04 16:06:11 -05:00
Nick Mathewson 645dc10148 Make TorError implement Clone.
This patch makes only minimal changes in lower-level error types:
we have more refactoring to do.
2022-02-04 16:06:11 -05:00
Nick Mathewson cf4edcac82 Fix a doc link. 2022-02-04 16:03:39 -05:00
Nick Mathewson 8effe24855 Merge branch 'error-poc' into 'main'
New error handling proof of concept

See merge request tpo/core/arti!262
2022-02-04 19:14:10 +00:00
Nick Mathewson f973fe5060 Require backtrace 0.3.8.
This is the first version that builds correctly on our CI.  It's
from back in 2018, so requiring it shouldn't cause any major
problems.
2022-02-04 13:52:46 -05:00
Nick Mathewson d594254f58 Merge branch 'fix-links' into 'main'
Properly linkify two doc comment xrefs to issues

See merge request tpo/core/arti!290
2022-02-04 16:26:51 +00:00
Ian Jackson a49889f116 Properly linkify two doc comment xrefs to issues
Fixes these messages:

  warning: this URL is not a hyperlink
   --> crates/arti/src/watch_cfg.rs:115:5
    |
115 | /// https://github.com/notify-rs/notify/issues/165 and
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://github.com/notify-rs/notify/issues/165>`
    |
    = note: `#[warn(rustdoc::bare_urls)]` on by default
    = note: bare URLs are not automatically turned into clickable links

warning: this URL is not a hyperlink
   --> crates/arti/src/watch_cfg.rs:116:5
    |
116 | /// https://github.com/notify-rs/notify/pull/166 .
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://github.com/notify-rs/notify/pull/166>`
    |
    = note: bare URLs are not automatically turned into clickable links
2022-02-04 15:11:44 +00:00
Ian Jackson 6c2f9dac16 channel errors: Include what we were doing 2022-02-04 15:03:19 +00:00
Ian Jackson 5b54d3e08e errors: Add some TODOs as per discussion comments 2022-02-04 14:52:30 +00:00
Ian Jackson 87270415f0 errors: ErrorKind::TODO: Fix typo in message
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/262#note_2772816
2022-02-04 14:46:35 +00:00
Ian Jackson ca960df6b1 errors: Change docs for ErrorKind to refer to Arti
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/262#note_2772810
2022-02-04 14:43:58 +00:00
Ian Jackson f5e874cf91 errors: Drop "Error" and "Failed" from various enum variants 2022-02-04 14:42:37 +00:00
Ian Jackson 0462533863 Box the Error in a TorError
This will get quite large and boxing it here is very convenient.

This also avoids us exposing a large error type to our callers.
2022-02-04 14:42:37 +00:00
Ian Jackson 43fc900284 errors: Handle exit circuit creation failure the new way 2022-02-04 14:42:37 +00:00
Ian Jackson b3cebf163f errors: Handle circmgr setup errors differently
The motivation for doing this now is to remove the `#[from]` so we
would spot where operationsl circuit setup failures were handled.
(But it turns out that they are turned into internal errors!)

Perhaps this will want to become a different error type from circmgr
in due course, but for now we simply use a bespoke variant of
TorError.

It will want its own Kind.  The TODO in the HasKind impl marks
this (amongst much else here).
2022-02-04 14:42:37 +00:00
Ian Jackson d21b2cc6f5 tor-circmgr: Introduce TargetPorts with a pretty Display impl 2022-02-04 14:42:37 +00:00
Ian Jackson 09116d7b4d tor-circmgr::Error: impl HasKind 2022-02-04 14:42:37 +00:00
Ian Jackson f4813e249c tor-circmgr: Handle channel creation errors in the new style 2022-02-04 14:42:37 +00:00
Ian Jackson 0a1cda6886 tor-chanmgr::Error: impl HasKind 2022-02-04 14:42:37 +00:00
Ian Jackson 2a471ffd1a tor-chanmgr: Handle IO errora in the new style
Two ? in the tests become expects, which will do.  That avoids having
to construct a proper error with context here.
2022-02-04 14:42:37 +00:00
Ian Jackson 2101dd5e39 errors: Introduce error_detail feature
Right now we must always expose the `Error` type since we haven't
converted everything.
2022-02-04 14:42:37 +00:00
Ian Jackson 9a293a1f6f errors: Refer to err::Error in some bits of arti_client
We are going to make the top-level Error type conditionally hidden.
2022-02-04 14:42:37 +00:00
Ian Jackson 9e577f9a17 errors: Introduce TorError
Still much to do here.
2022-02-04 14:42:37 +00:00
Ian Jackson 14f67609f7 errors: Initial impl HasKind in arti-client, ErrorKind::TODO
This involves making a temporary ErrorKind::TODO.  That will continue
to exist until all errors (at least, the ones that make it out to
here) can be properly categorised.

Introducing this will let us work from the top and bottom towards the
middle.
2022-02-04 14:42:37 +00:00
Ian Jackson bdd58bb6b7 errors: impl HasKind for GuardMgrError 2022-02-04 14:42:37 +00:00
Ian Jackson a779c1f1dd spawn errors: tor-guardmgr: Use formulaic pattern
This makes this like all the others, and is marginally shorter
2022-02-04 14:42:37 +00:00
Ian Jackson 2f1d98403b spawn errors: Fix tor-dirmgr 2022-02-04 14:42:37 +00:00
Ian Jackson de17c64412 spawn errors: Fix arti-client, tor-chanmgr, tor-circmgr
Provide an enum variant to contain the SpawnError and a From impl.

We use `#[from]` here because it doesn't really make sense to attach
any context, as it's not likely to be very relevant.
2022-02-04 14:42:37 +00:00
Ian Jackson 68d0ec437f spawn errors: impl HasKind for futures::SpawnError
This needs two kinds.  We have decided to treat a non-shutdown
SpawnError as "unexplained" rather than as an InternalError.

There are many crates whose
  From<futures::task::SpawnError> for Error
erroneously treat it as an internal error.  We will fix them in a moment.
2022-02-04 14:42:37 +00:00
Ian Jackson a623982197 tor_persist::Error: impl HasKind and adjust comments
And change the comments to slightly reinterpret these errors, to
relate to the circumstances rather than error generation site.
2022-02-04 14:42:37 +00:00