Commit Graph

982 Commits

Author SHA1 Message Date
Ian Jackson fe864c17c6 impl From<TorAddrError> for tor_error::Error
It auto-converts to ErrorDetail but add this for convenience of
callers which don't want to look into that unstable API.
2022-02-23 14:34:53 +00:00
Nick Mathewson 92141c6d72 Merge remote-tracking branch 'origin/mr/340' 2022-02-23 09:29:40 -05:00
Nick Mathewson 6ea0df166a Merge branch 'client_builder' into 'main'
Make a TorClientBuilder API.

Closes #350

See merge request tpo/core/arti!337
2022-02-23 14:14:32 +00:00
eta 9960064720 examples/hook-tcp: add some comments, rework lifetimes a bit
Try to make the `hook-tcp` example a bit easier to read by
adding/changing comments, and renaming the lifetimes for
`async_trait`-generated trait methods.
2022-02-23 13:59:03 +00:00
Ian Jackson 0cf9751d7f arti-hyper: Move hyper example from arti-client
Code motion and consequential dependency adjustments.
2022-02-23 13:55:17 +00:00
Ian Jackson 0f80be6b35 arti-hyper: empty crate skeleton 2022-02-23 13:55:14 +00:00
Ian Jackson f8d17bce83 Add missing documentation for TLS features to two readmes 2022-02-23 13:53:45 +00:00
trinity-1686a ce679ad72a implement correct handling of connection close and add comment explaining goal of the example 2022-02-23 13:29:37 +00:00
trinity-1686a b5707a98e7 add drop on CustomTcpStream to catch disconnection without close 2022-02-23 13:29:37 +00:00
trinity-1686a 81d7747d7b add example of tcp hook
this required to make additional types public
2022-02-23 13:29:37 +00:00
Ian Jackson fd288f90f9 Documentation suggestion from review. 2022-02-23 13:19:10 +00:00
Ian Jackson 05bf12edfa Cleanups on !340 from @diziet 2022-02-23 13:17:27 +00:00
eta 05257da72d Merge branch 'restore_needless_borrow_check' into 'main'
Remove clippy::needless_borrow exception in CI.

Closes #310

See merge request tpo/core/arti!338
2022-02-23 13:15:15 +00:00
Nick Mathewson 784f1531bb Make NoLock into BadApiUsage.
To implement this, we had to refactor the tor_circmgr api for
flushing state changes to disk, so that it checks if it has the lock,
and only then tries to store.
2022-02-22 16:13:37 -05:00
Nick Mathewson a2e2663e90 Eliminate RequestedResourceAbsent kind.
There was only one use of this, and it was in as-yet-unused relay-only
code.

Removing this type required refactoring the relay onion handshake code
to use its own error type, which is probably clever anyway.
2022-02-22 16:00:25 -05:00
Nick Mathewson 789e6c87b8 Fold NamespaceFull into BadApiUsage. 2022-02-22 15:44:49 -05:00
Nick Mathewson 4cedc1a190 Rename RemoteNameError to RemoteHostNotFound
This is a bit ugly but we need it to work around the problem where
exits aren't always clear about _why_ a hostname lookup failed.
2022-02-22 15:43:27 -05:00
Nick Mathewson 0ce4a12976 Replace TorNetworkError with TorDirectoryError
This is still not as specific as we want; but there's already a TODO
comment in tor-dirclient::err about fixing that at some point in the
future.
2022-02-22 15:41:01 -05:00
Nick Mathewson 7d4a57d5fa Rename TorConnectionFailed to TorAccessFailed 2022-02-22 15:38:13 -05:00
Nick Mathewson 3f0d50e08f Fold UnexplainedTaskSpawnFailure into Internal. 2022-02-22 15:37:22 -05:00
Nick Mathewson 0e242831b2 Rename TorShuttingDown to ArtiShuttingDown 2022-02-22 15:36:09 -05:00
Nick Mathewson 0d079071fe Replace RemoteRefused with CircuitRefused.
Also document that it's a lower-level error kind.
2022-02-22 15:34:46 -05:00
Nick Mathewson f018d0c74b Rename RemoteIdMismatch to RelayIdMismatch. 2022-02-22 15:32:08 -05:00
Nick Mathewson 04ca1f662f Fold EK::Canceled into TransientFailure
Also add some TODO comments in circmgr for future work.
2022-02-22 15:30:12 -05:00
Nick Mathewson 5351aaa308 Fold AlreadyClosed into BadApiUsage 2022-02-22 15:25:24 -05:00
Nick Mathewson a02737be1c Add TODOs for errorkinds we mean to fix later
Per #348, These are the cases that we meant to fix down the road, but
not in 0.1.0.
2022-02-22 15:22:49 -05:00
Nick Mathewson e62afdf79a Merge remote-tracking branch 'origin/mr/335' 2022-02-22 12:46:51 -05:00
Nick Mathewson 4d4c7f47a7 Merge branch 'error-report' into 'main'
Improve error messages from arti cli

See merge request tpo/core/arti!331
2022-02-22 17:31:18 +00:00
Ian Jackson be2bb0ccfb tor_error::Report: add tests 2022-02-22 14:57:16 +00:00
Ian Jackson 01c5e07087 tor_error::Report: Add bound to struct
This is more typing in the definition but it produces much better
error messages if you try to Report(foo).to_string()
2022-02-22 14:53:17 +00:00
Ian Jackson 06964bbfbb Move program name printing to report_and_exit 2022-02-22 14:52:47 +00:00
Ian Jackson d1f4e9f3c6 Merge branch 'pending_error' into 'main'
Handle panics from circuit construction

Closes #347

See merge request tpo/core/arti!336
2022-02-22 10:58:09 +00:00
Nick Mathewson dd55f5ce2d Remove clippy::needless_borrow exception in CI.
This exception is no longer necessary now that the underlying CI bug
is fixed.
2022-02-20 09:09:38 -05:00
Nick Mathewson c910226b55 Make a TorClientBuilder API.
This is a defensive API choice to protect against the possibility
that we'll want to add a bunch of other non-config options in
the future.

Closes #350
2022-02-18 15:28:31 -05:00
Nick Mathewson 3ff9b187ea Handle panics from circuit construction.
We handle them by reporting them to task that's waiting for the
circuit, then relaying the panic.

Doing so allows the waiting task to distinguish panics
(EK::Internal) from cases where the reactor dropped the task
entirely (EK::ReactorShuttingDown).  And doing _that_ removes one
case of EK::Canceled, which helps us on our goals towards #348.

Closes #347.
2022-02-18 14:22:38 -05:00
Ian Jackson 7d403b42fe Placate clippy on nightly, properly
I c&p this lint suppression but from a cli option printed by clippy,
and I didn't notice the need to change the - to _.
2022-02-18 18:07:43 +00:00
Nick Mathewson 0513a1d8a6 Edit tor-error comment to reflect shared ideas 2022-02-18 12:51:05 -05:00
Ian Jackson 4182c30b63 Placate clippy on nightly 2022-02-18 17:37:21 +00:00
Ian Jackson f9d2ecad27 Bump anyhow minimal version to 1.0.23
This is the first one where anyhow::Error impl AsRef<dyn StdError>

We want this because we want to add error reporting functionality
which works with all kinds of errors, which means we need an
anyhow::Error which can be vieweed as a StdError.

(The alternative would be to deref at the call sites of
report_and_exit, making it less ergonomic.)

anyhow 1.0.23 is from November 2019.
2022-02-18 17:04:57 +00:00
eta b4c0bd6ef3 Merge branch 'proxy-sooner' into 'main'
arti cli: socks proxy: Start listening immedately

See merge request tpo/core/arti!333
2022-02-18 16:06:08 +00:00
Ian Jackson e0630fda7e arti cli: Add some anyhow context() calls 2022-02-18 14:05:40 +00:00
Ian Jackson 3f8d566a7a arti cli: socks proxy: Start listening immedately
This makes arti less awkward to use.
2022-02-18 14:04:42 +00:00
Ian Jackson 460b94ef14 arti cli: Do config watch setup before entering future select
IMO this clarifies things a bit, and makes things more deterministic.
2022-02-18 13:55:12 +00:00
Nick Mathewson e3e3f9934b Move the main body of our circuit-launching task into a new function
This reduces our nesting, and will help us handle panics.
2022-02-18 08:33:50 -05:00
Dimitris Apostolou 5d61c3cf88
Fix typos 2022-02-18 15:29:02 +02:00
eta 74aa16e87a Merge branch 'script-filenames' into 'main'
Remove extension from scripts

See merge request tpo/core/arti!328
2022-02-18 12:50:16 +00:00
Ian Jackson f5a489e28c Placate rustfmt
I think all of this diff is a strict disimprovement, but whatever.
2022-02-18 12:48:17 +00:00
Ian Jackson 4a007beba7 Placate clippy 2022-02-18 12:48:00 +00:00
Ian Jackson 0eba24cb43 Add missing docs for report_and_exit 2022-02-18 12:46:58 +00:00
Ian Jackson 1e811a71d3 Add a missing anyhow context() call 2022-02-18 12:10:31 +00:00
Ian Jackson 8c4726b55e Provide error reporter and use it in the arti binary 2022-02-18 12:10:31 +00:00
Ian Jackson ccb4604237 Merge branch 'no-http-status-err' into 'main'
dirclient: Remove HttpStatus error variant

Closes #349

See merge request tpo/core/arti!329
2022-02-18 12:04:54 +00:00
Ian Jackson 1c301230e4 rename *.py scripts to bare name
Update all references.  There are three remaining hits for
  git-grep '\.py\b'
all of which are scripts in "little-t-tor", not here in arti.
2022-02-18 11:46:06 +00:00
Nick Mathewson 1572fc520e spelling fix 2022-02-17 15:59:56 -05:00
Nick Mathewson 023ff75a64 Add #[display] annotations for remaining ErrorKinds. 2022-02-17 15:18:19 -05:00
Nick Mathewson 64a0d4dce5 dirclient: Remove HttpStatus error variant
Getting a non-200 status is no longer a failure condition; it's just
a different kind of answer.

Closes #349.
2022-02-17 15:12:00 -05:00
Nick Mathewson 83d001d661 Merge branch 'remaining-errors' 2022-02-17 14:22:47 -05:00
Nick Mathewson 2f6160965d Fix compilation on main 2022-02-17 14:19:21 -05:00
Nick Mathewson 80be59497e Merge branch 'clippy-followup' into 'main'
Remove some needless refs and slicing

See merge request tpo/core/arti!327
2022-02-17 18:25:54 +00:00
Ian Jackson 6503d8ce03 Avoid recursive From impls
These (&foo).into() constructions are needed so we use the
implemnetation of `From<&Foo>`, not a recursive call to this very
function.

This is a partial revert of the previous commit.  I'm making this a
separate commit for the benefit of posterity.
2022-02-17 17:42:12 +00:00
Nick Mathewson a5e4e24537 Use TorConnectionFailed for failure to download directory. 2022-02-17 12:37:07 -05:00
Nick Mathewson 4c08141488 Clarify state vs cache in ErrorKind 2022-02-17 12:35:35 -05:00
Nick Mathewson 024ec61a1a Correct ErrorKinds for some tor-dirclient errors. 2022-02-17 12:26:18 -05:00
Nick Mathewson de86ac0b0f Rename CircuitTimeout to TorNetworkTimeout. 2022-02-17 12:22:51 -05:00
Nick Mathewson 034c5ba9f5 Rename ExitTimeout to RemoteNetworkTimeout. 2022-02-17 12:19:33 -05:00
Nick Mathewson 4db586cf00 tor_circmgr::Error: Sort variants by interesting-ness.
We can't use discriminants here now, but maybe we can in the future.
2022-02-17 12:12:04 -05:00
Nick Mathewson 550eb9e61b Tweak documentation on ErrorKind::Transient 2022-02-17 11:50:42 -05:00
eta a772d02578 Merge branch 'issue-325' into 'main'
Make CircMap open_ent_count O(1)

See merge request tpo/core/arti!302
2022-02-17 14:36:19 +00:00
Ian Jackson ce6fbac0d7 Merge branch 'bootstrap_second' into 'main'
arti: create TorClient first, then bootstrap.

Closes #336

See merge request tpo/core/arti!320
2022-02-17 14:21:04 +00:00
Ian Jackson 516a2a3de8 Merge branch 'typos' into 'main'
Fix typos

See merge request tpo/core/arti!326
2022-02-17 14:19:08 +00:00
Ian Jackson c9aa3b9937 tor-dirmgr: Use Bug type for sqlite-detected bugs
So we get a stack trace
2022-02-17 13:32:47 +00:00
Ian Jackson 1a9a209771 tor-dirmgr: Make sqlite_error_kind take rusqlite::Error
We're about to reuse this and we'll want it to take the higher-level
type.  Also it seems more proper like this.
2022-02-17 13:31:36 +00:00
Ian Jackson 9a6518fb81 tor-error: splitting/lumping guidelines 2022-02-17 13:31:11 +00:00
Ian Jackson 9a55290037 tor-dirclient: Error::HttpError: add a TODO saying to abolish 2022-02-17 13:31:11 +00:00
Ian Jackson 079f7fd1b8 ErrorKind::RemoteRefused: Expand on description, narrowing scope 2022-02-17 13:31:11 +00:00
Ian Jackson cca253ff9f ErrorKind::Csnceled: Expand on description 2022-02-17 13:31:11 +00:00
Ian Jackson 48e3ae6b79 ErrorKind::CircuitTimeout: Expand on description 2022-02-17 13:31:11 +00:00
Ian Jackson de70e15f21 ErrorKind::DirectoryExpired: Add possible deprecation notes 2022-02-17 13:31:11 +00:00
Ian Jackson 2d4901ccde tor-circmgr: errors: Use autoconversion for Bug 2022-02-17 13:31:03 +00:00
Ian Jackson bbcc871105 Remove some needless refs and slicing
Prompted by nightly's clippy (which has some false positives, so is
currently disabled).
2022-02-17 11:16:27 +00:00
Ian Jackson 094ddd7cd7 Add a comment about "&mut [&mut ]" 2022-02-17 11:07:52 +00:00
Ian Jackson 95e081ab44 Merge branch 'ptr_arg_fix' into 'main'
Re-enable clippy::ptr_arg where it had been disabled.

See merge request tpo/core/arti!323
2022-02-17 11:07:45 +00:00
Dimitris Apostolou ea929fd942
Fix typos 2022-02-17 12:55:59 +02:00
Yuan Lyu 7ab840785e Replace as_mut with deref impl for MutCircEnt 2022-02-16 17:23:16 -05:00
Yuan Lyu cc7023fb75 Make CircMap open_ent_count O(1) 2022-02-16 16:48:49 -05:00
Nick Mathewson 36314ad364 tor_error: a couple of spelling/formatting issues 2022-02-16 16:43:13 -05:00
Nick Mathewson 990753ca92 Finally remove ErrorKind::TODO.
Closes #322.
2022-02-16 16:40:57 -05:00
Nick Mathewson 0bdef96897 arti_client: provide Kinds for all errors. 2022-02-16 16:38:22 -05:00
Nick Mathewson 2a7087ff93 dirmgr: Remember where netdocs came from.
This isn't complete (see TODO), but it's enough to let us report the
right ErrorKind if something fails to parse.
2022-02-16 16:28:23 -05:00
Nick Mathewson 4bb7c97399 dirmgr: eliminate StringParsingError.
It had too many possible Kinds depending on what kind of string had
failed to parse.

I decided to use #[source] here instead of #[from], so that we
would have to explicitly convert these errors where they show up.
2022-02-16 16:02:28 -05:00
Nick Mathewson f71473cf73 dirmgr: HasKind for internal and sqlite errors
At first I had thought that all sqlite errors would be internal, but that's
not the case.
2022-02-16 15:48:24 -05:00
Nick Mathewson 9e03643f65 dirmgr: implement HasKind for the easier variants 2022-02-16 15:22:21 -05:00
eta 30439f9dc2 Merge branch 'eta/lazy-init' into 'main'
arti-client: add ability to automatically bootstrap

Closes #278

See merge request tpo/core/arti!322
2022-02-16 20:08:38 +00:00
Nick Mathewson 49c87fa8f9 Implement HasKind for tor_dirclient::Error 2022-02-16 14:53:58 -05:00
Nick Mathewson 7f9bbcb437 dirclient: remove an unused error type. 2022-02-16 14:42:07 -05:00
Nick Mathewson 543916e812 Clarify and rename PendingCanceled
From its old name, this error had implied that we were giving no
useful information when we were waiting on a pending cirucit request
that failed.  In fact, this error would only happen if we dropped the
`mpsc::Sender` for a circuit attempt without reporting success or
failure.
2022-02-16 14:35:06 -05:00
Nick Mathewson 1d773e748f Provide a better ErrorKind from RetryError.
(Instead of reporting the _last_ error, report the _worst_ error.)
2022-02-16 14:35:06 -05:00
Nick Mathewson c1899f787b circmgr: Add a Kind for speculative guard failure.
These errors should almost never be seen by the user; we should instead
retry the circuit.  But they _can_ be seen by the use if selecting a
guard takes too long, or too many attempts. (Therefore, they aren't true
"internal" errors.)

I suspect that we might not want to keep this TransientFailure kind, but
I'm not sure what else to do here for now.
2022-02-16 14:35:06 -05:00
Nick Mathewson 96d856e264 Add kinds for *most* circmgr errors.
There are a couple of tricky ones I'll do separately.
2022-02-16 14:35:06 -05:00
Nick Mathewson 900007585a circmgr: Port InternalError to use Bug. 2022-02-16 14:35:06 -05:00
Nick Mathewson f572baa7ad Merge branch 'chanmgr-error' into 'main'
Implement HasKind for tor-chanmgr::Error

See merge request tpo/core/arti!324
2022-02-16 19:34:42 +00:00
eta 790ea4af4b arti-client: add ability to automatically bootstrap
The new `BootstrapBehavior` enum controls whether an unbootstrapped
`TorClient` will bootstrap itself automatically (`Ondemand`) when an
attempt is made to use it, or whether the user must perform
bootstrapping themselves (`Manual`).

The `lazy-init` example shows how you could write a simple
`get_tor_client()` function that used a global `OnceCell` to share
a Tor client across an entire application with this API.

closes arti#278
2022-02-16 19:29:16 +00:00
Ian Jackson 716a060191 Merge branch 'netdir-error' into 'main'
Simplify tor-netdir::Error by a *lot*

See merge request tpo/core/arti!319
2022-02-16 17:52:52 +00:00
Nick Mathewson caa70fde35 tor-chanmgr: use Bug types. 2022-02-16 11:55:47 -05:00
Nick Mathewson 10bca35bba Implement HasKind for tor-chanmgr::Error
(There will be a folowup to work on internal errors here.)
2022-02-16 11:55:47 -05:00
Nick Mathewson 2147d0849f Merge branch 'cell-proto-error' into 'main'
tor-cell and tor-proto: provide HasKind.

See merge request tpo/core/arti!304
2022-02-16 16:55:14 +00:00
Nick Mathewson ed57157d84 Re-enable clippy::ptr_arg where it had been disabled.
In one of the two places, nightly no longer warns.  In the other
place, it's fine for nightly to warn: I just fixed the code to take
a slice instead.

Partial revert of 856aca8791.

Resolves part of #310.
2022-02-16 11:33:12 -05:00
Nick Mathewson 62a62b6dfd tor_proto::Error: Fix an incomplete sentence. 2022-02-16 11:09:59 -05:00
eta 967f0a45f3 Merge branch 'ticket_344' into 'main'
Refactor tor-netdoc a bit more, to use Bug right.

See merge request tpo/core/arti!316
2022-02-16 15:21:11 +00:00
Yuan Lyu 98b1a5a279 Move persistent state flush from client to circmgr 2022-02-15 20:04:45 -05:00
Nick Mathewson c6c4531652 arti: create TorClient first, then bootstrap.
This change is possible now that #293 is done.

As an immediate benefit, it allows us to start monitoring the
configuration files immediately, and not only after we're done
bootstrapping the client.

Closes #336.
2022-02-15 17:32:08 -05:00
Nick Mathewson 058e4d7705 tor-netdir: Split testnet errors into a new type
There's no reason to have the test-network-construction code share an
error enum with the main netdir code.
2022-02-15 14:43:36 -05:00
Nick Mathewson ceb8e8c1e2 tor-netdir: remove unused error variants
This turns out to have been most of them, which
simplifies matters a lot.
2022-02-15 14:36:15 -05:00
Nick Mathewson 7c7bf2bd03 Fix a rustdoc error. 2022-02-15 13:46:58 -05:00
Nick Mathewson 6bd21d4372 Refactor tor-netdoc a bit more, to use Bug right. 2022-02-15 10:22:38 -05:00
Nick Mathewson 13f39ed896 Minimal compilation fix: InternalError=>Bug
This is a followup for !314 and !310 to fix compilation on main.
2022-02-15 10:13:08 -05:00
Nick Mathewson 7b6a7a57d3 Merge branch 'doc-errors' into 'main'
Refactor errors in tor-netdoc

See merge request tpo/core/arti!314
2022-02-15 15:09:48 +00:00
Nick Mathewson 6b611d6dea Update tor-proto errors to latest API. 2022-02-15 09:57:03 -05:00
Nick Mathewson 8b9b42514a Update tor-cell errors to latest API 2022-02-15 09:56:53 -05:00
Nick Mathewson 4af279b173 Make tor-proto::Error implement HasKind.
This took some refactoring, and gave an opportunity to notice
a few error variants that weren't being used, or didn't mean
what they said on the tin.
2022-02-15 09:41:47 -05:00
Nick Mathewson f23f375e42 tor-proto: use InternalError for internal errors. 2022-02-15 09:41:11 -05:00
Nick Mathewson da0e9e456c tor-cell: provide HasKind.
Additionally, refactor the IoError out of tor_cell::Error:
nothing in TorCell created this; it was only used by tor_proto.

This required refactoring in tor_proto to use a new error type. Here I
decided to use a new CodecError for now, though we may refactor that
away soon too.
2022-02-15 09:41:10 -05:00
eta cb7f068c3b Typo fix from@eta 2022-02-15 14:34:59 +00:00
Ian Jackson 8688069add tor_error::Bug: change Display impl to use kind
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/310#note_2777626

The message from the kind is precisely right.
2022-02-15 13:58:54 +00:00
Ian Jackson ad6cb60d8a BadApiUsage: change Display impl capitalisation
Now it maches the others
2022-02-15 13:58:52 +00:00
Ian Jackson 5d636738eb Rename BadApiUsage from BadAPIUsage
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/310#note_2777519
mutatis mutandi.

And, fix a leftover instance with an old idea of what this was called.
2022-02-15 11:46:54 +00:00
Ian Jackson 97a0a7359b tor-socksproto: Use bad_api_usage! rather than ad-hoc Invalid error 2022-02-15 11:40:24 +00:00
Ian Jackson b8f928e4f5 Make Bug from InternalError, add bad_api_usage! and into_bad_api_usage!
Including supporting machinery, new kind field, etc.
2022-02-15 11:40:24 +00:00
Ian Jackson 5d87ca8ad7 New name and semantics for BadAPIUsage (was BadArgument) 2022-02-15 11:32:19 +00:00
Nick Mathewson e80d472beb Merge branch 'error-socksproto-autoconvert' into 'main'
Provide, and use From impl for InternalError

See merge request tpo/core/arti!315
2022-02-14 20:57:24 +00:00
Nick Mathewson 72221b0b77 Merge branch 'explain_into_tor_addr' into 'main'
More docs for IntoTorAddr

Closes #253

See merge request tpo/core/arti!305
2022-02-14 20:34:50 +00:00
Nick Mathewson a44b13c93a More docs for IntoTorAddr 2022-02-14 20:34:50 +00:00
Nick Mathewson 31075e8046 Run rustfmt. 2022-02-14 14:47:42 -05:00
eta d7478e2675 Merge branch 'ticket_337' into 'main'
Simplify wait_for_bootstrap to use a Mutex.

Closes #337

See merge request tpo/core/arti!308
2022-02-14 19:46:23 +00:00
eta 29daf5a74a Merge branch 'warn_not_deny' into 'main'
Change deny(clippy::all) to warn(clippy::all).

Closes #338

See merge request tpo/core/arti!306
2022-02-14 19:45:18 +00:00
Nick Mathewson e4321bbae2 Merge remote-tracking branch 'origin/mr/313' 2022-02-14 14:25:28 -05:00
Ian Jackson 8db7ab8148 Merge branch 'error-kind-protocol' into 'main'
Split up ErrorKind::ProtocolViolation

See merge request tpo/core/arti!312
2022-02-14 19:07:00 +00:00
Ian Jackson 4774cbd18d Provide, and use From impl for InternalError
Adding this autoconversion is quite safe since every error generation
site is explicit and has its own context, and we don't really need to
add more.

This simplifies the code and will simplify future work.
2022-02-14 18:48:35 +00:00
Ian Jackson 65e2deaf29 Merge branch 'error-kind-notimp' into 'main'
Split up ErrorKind::NoSupport

See merge request tpo/core/arti!311
2022-02-14 18:31:56 +00:00
Nick Mathewson b6d23c36be Refactor tor_netdoc::Error
This error type doesn't impement HasKind, since the kind will depend
on context.

However, the existing implementation was pretty messy and inconsistent:
Some errors had positions, some didn't.
Some took messages as str, some as String.
Some had internal errors that were somewhat orthogonal to their actual
types.

This commit refactors tor_netdoc::Error to use a ParseErrorKind, and
adds a set of convenience functions to add positions and
messages to the errors that need them.
2022-02-14 13:08:28 -05:00
Ian Jackson 4d14398fe1 Split up ErrorKind::ProtocolViolation 2022-02-14 17:55:56 +00:00
Ian Jackson b74f3a3c10 ErrorKind::NotImplemented: fix two tests 2022-02-14 17:54:05 +00:00
Ian Jackson 02959576bb tor_socksproto::Error HasKind fix two delegations
We should not generally explicitly specify a kind for errors which
contain a more detailed error which itself has a kind.  Stating the
kind literally is a latent bug, which becomes a real bug if the
contained type's kind changes or starts to vary.

(There may be exceptions to this principle but this isn't one of
them.)
2022-02-14 17:46:19 +00:00
Nick Mathewson 9e88f279d9 Merge branch 'error-kind-config-transition' into 'main'
Clarify ErrorKind::InvalidConfigTransition

See merge request tpo/core/arti!309
2022-02-14 16:51:32 +00:00
Ian Jackson 30ebb1358a Split up ErrorKind::NoSupport 2022-02-14 16:06:45 +00:00
Nick Mathewson b27c51d3a2 netdoc: Make doc-build errors a separate type
Every other case of tor_netdoc::Error means a parse failure.  This one,
though, means a failure to construct  a document.
2022-02-14 10:46:04 -05:00
Nick Mathewson eeab17f811 Merge branch 'useless_qm' into 'main'
dirmgr: Remove a useless Ok(x?)

See merge request tpo/core/arti!307
2022-02-14 15:42:51 +00:00
Ian Jackson 3a9a4b6532 Clarify ErrorKind::InvalidConfigTransition 2022-02-14 15:41:40 +00:00
Nick Mathewson 61867613a2 netdoc: remove Error::Untimely.
Nothing creates this.
2022-02-14 10:28:58 -05:00
Nick Mathewson 9e3d0bc817 Merge branch 'update_if_zero' into 'main'
Use atomic set-and-check to update OptTimestamps if none.

See merge request tpo/core/arti!297
2022-02-14 15:18:28 +00:00