aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-bytes/src/err.rs
Commit message (Collapse)AuthorAgeFilesLines
* Add take_until_with_limit methods for better developer experience,pryty262026-07-021-0/+9
| | | | | These methods provide modified error handling, changed take_until to use take_until_with_limit and added tests.
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-071-2/+2
| | | | | | | | | | | | | | First, run ``` git grep -l "^edition =" | xargs perl -i -pe 's/^edition *=.*/edition = "2024"/;' ``` Second, manually verify that all Cargo.toml files have changed, and nothing else has changed. Third, run cargo fmt again.
* tor-bytes: Restore the message for Error::TruncatedIan Jackson2024-10-011-1/+1
| | | | | This variant is deprecated but it still ought to have a message so long as it exists.
* tor_bytes: Rename new_truncated_for_test to new_incomplete_for_testIan Jackson2024-09-121-2/+2
| | | | No semver implications since this wasn't in the last release.
* tor-bytes: Add note about other kinds of invalid messageIan Jackson2024-09-111-0/+11
| | | | | Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2407#note_3075485
* tor-bytes: Add imprecations about Incomplete and MissingDataIan Jackson2024-09-111-0/+17
| | | | | Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2407#note_3075483
* tor-bytes: Do many missed renames of Truncated to IncompleteIan Jackson2024-09-111-1/+1
|
* tor-bytes: Rename Truncated to Incomplete, and restore old Truncated as ↵Ian Jackson2024-09-111-2/+8
| | | | | | | | | deprecated Incomplete is a better name. This lets us use Truncated for the old, deprecated, conflation of "Incomplete" with what is now "MissingData".
* tor-bytes: Only report Truncated for errors at the outer levelIan Jackson2024-09-111-3/+8
| | | | | | | | | | | This is item 1 from https://gitlab.torproject.org/tpo/core/arti/-/issues/1614#note_3074562 and the alternative to item 2 presented in the 2nd half of https://gitlab.torproject.org/tpo/core/arti/-/issues/1614#note_3074648 (Item 3 was done earlier, but now we change the behaviour.) Fixes #1614.
* tor-bytes: Error: provide and call Error::incomplete_error (tidy)Ian Jackson2024-09-111-4/+1
| | | | | Tidy up an error message. Now this can be on one line with variable name interpolation.
* tor-bytes: Error: provide and call Error::incomplete_error (fmt)Ian Jackson2024-09-111-1/+3
|
* tor-bytes: Error: provide and call Error::incomplete_errorIan Jackson2024-09-111-5/+2
| | | | | | | | | | | | | | | | | | | We introduce the new constructor and call it at the error generation sites. But there is still not yet any functional change. Change the type of Truncated's field to be Sensitive. The original reason for not doing this no longer applies, since we don't generally want to open-code construction of this variant. Conveniently, changing the type means we get to find all the sites where one *is* constructed and adjust them. In reader.rs and tor-proto we can just call incomplete_error. In tor-cell, there's a call site where we previously provided an underestimate, and where the Reader isn't available. We adjust that ad-hoc but this is fine because the error variant will change. (relaycell is using a Reader from from_slice.)
* tor-bytes: derive impl PartialEq for ErrorIan Jackson2024-09-111-17/+27
| | | | | | | I just perpetrated a bug by adding a variant to this which ended up not PartialEq to itself. This open-coded match is a footgun. No functional change.
* tor-bytes: Error::Truncated: mark the deficit as Sensitive (fmt)Ian Jackson2024-09-101-2/+4
|
* tor-bytes: Error::Truncated: mark the deficit as SensitiveIan Jackson2024-09-101-1/+6
| | | | | Suggested in https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2390#note_3072975
* tor-bytes: Add a deficit field to Error::TruncatedIan Jackson2024-09-101-5/+8
| | | | This will allow us to fix #1592, but it doesn't do so yet.
* Introduce and use tor_bytes::Error::new_truncated_for_testIan Jackson2024-09-101-0/+15
| | | | | | | | This is going to want to do something more complicated (as described in the docs). In this commit we change all the tests that are expecting Truncated errors. That reduces noise in the next commit.
* tor-bytes: deprecate always_bug with From traitEmil Engler2023-08-171-0/+11
| | | | | | This commit deprecates the `EncodeError::always_bug` function with a `From<EncodeError> for Bug` trait, which is a more semantically correct way to perform this action.
* Change tor_bytes::Error::BadMessage to a Cow.Nick Mathewson2023-02-091-0/+9
| | | | | | | | | | Actually, to avoid making a breaking change, I'm deprecating BadMessage and creating a new InvalidMessage variant that takes a Cow. This way I don't need to track every crate that re-exposes tor_bytes::Error and call this a breaking change in those. Making this change will allow tor_bytes errors to be much more helpful.
* tor-bytes: Implement conversion from EncodeError to BugIan Jackson2023-01-241-1/+16
|
* Add a Bug variant to tor-bytes::EncodeError.Nick Mathewson2022-07-111-1/+7
| | | | This will help down the line as we make more writers fallible.
* tor-bytes: Split EncodeError from ErrorNick Mathewson2022-06-231-3/+13
| | | | | | | | | | | Since there is currently only one error type that can occur when encoding, it doesn't make sense to use the full Error type here. This split will help us downstream, as we no longer need to categorize tor_bytes::Error as "an error in encoding or decoding". I considered renaming Error to DecodeError, but that had pretty huge downstream effects, and didn't seem to be worth it.
* Style fixes to tor-bytes errors.Nick Mathewson2022-06-221-5/+9
| | | | | Also note an issue with the design of tor-bytes::Error that should probably go in a separate MR.
* tor-bytes: Prepare errors for nested reader/writerIan Jackson2022-06-091-1/+5
| | | | Writing is going to be able to give errors too.
* Make Bug from InternalError, add bad_api_usage! and into_bad_api_usage!Ian Jackson2022-02-151-2/+2
| | | | Including supporting machinery, new kind field, etc.
* tor-bytes: Use InternalError.Nick Mathewson2022-02-091-2/+15
| | | | | | This crate's Error type is too low-level to have an ErrorKind, but it does make sense to use InternalError for the internal errors here.
* Move all crates into a `crates` subdirectory.Nick Mathewson2021-08-271-0/+29
This will cause some pain for now, but now is really the best time to do this kind of thing.