about summary refs log tree commit diff
path: root/library/std/src/error.rs
AgeCommit message (Collapse)AuthorLines
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-13/+13
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
2022-01-26Improve Duration::try_from_secs_f32/64 accuracy by directly processing ↵Артём Павлов [Artyom Pavlov]-1/+1
exponent and mantissa
2022-01-13Rollup merge of #91938 - yaahc:error-reporter, r=m-ou-seMatthias Krüger-4/+643
Add `std::error::Report` type This is a continuation of https://github.com/rust-lang/rust/pull/90174, split into a separate PR since I cannot push to ```````@seanchen1991``````` 's fork
2022-01-10Eliminate "boxed" wording in `std::error::Error` documentationdavid-perez-6/+6
In commit 29403ee, documentation for the methods on `std::any::Any` was modified so that they referred to the concrete value behind the trait object as the "inner" value. This is a more accurate wording than "boxed": while putting trait objects inside boxes is arguably the most common use, they can also be placed behind other pointer types like `&mut` or `std::sync::Arc`. This commit does the same documentation changes for `std::error::Error`.
2022-01-07silence tidy errorsJane Lusby-10/+4
2022-01-07Implement `TryFrom<char>` for `u8`Ian Douglas Scott-0/+3
Previously suggested in https://github.com/rust-lang/rfcs/issues/2854. It makes sense to have this since `char` implements `From<u8>`. Likewise `u32`, `u64`, and `u128` (since #79502) implement `From<char>`.
2021-12-16attempt to make Report usable with Box dyn Error and fn mainJane Lusby-103/+201
2021-12-16more docs improvementsJane Lusby-35/+207
2021-12-16add a panicking exampleJane Lusby-4/+51
2021-12-16Update report output and fix examplesJane Lusby-35/+160
2021-12-14Update std::error::Report based on feedbackJane Lusby-27/+47
2021-10-27Fix broken doctestSean Chen-2/+2
2021-10-27Format doctestSean Chen-45/+10
2021-10-27Add `rust` annotation to doctestSean Chen-1/+1
2021-10-27Attempt to fix tidy errorsSean Chen-79/+54
2021-10-22Change `source` field to `error`Sean Chen-8/+8
2021-10-22Have `pretty` and `show_backtrace` accept booleansSean Chen-5/+5
2021-10-22Try commiting againSean Chen-1/+244
2021-10-04Stabilize try_reserveKornel-1/+1
2021-09-21Impl `Error` for `FromSecsError` without foreign typembartlett21-1/+2
Using it through the crate-local path in `std` means that it shouldn't make an "Implementations on Foreign Types" section in the `std::error::Error` docs.
2021-09-18Fix typoondra05-2/+2
Removed extra spaces in front of commas
2021-06-15Rollup merge of #82179 - mbartlett21:patch-5, r=joshtriplettYuki Okushi-0/+3
Add functions `Duration::try_from_secs_{f32, f64}` These functions allow constructing a Duration from a floating point value that could be out of range without panicking. Tracking issue: #83400
2021-06-14Add functions `Duration::try_from_secs_{f32, f64}`mbartlett21-0/+3
This also adds the error type used, `FromSecsError` and its `impl`s.
2021-04-02Document "standard" conventions for error messagesAleksey Kladov-8/+15
These are currently documented in the API guidelines: https://rust-lang.github.io/api-guidelines/interoperability.html#error-types-are-meaningful-and-well-behaved-c-good-err I think it makes sense to uplift this guideline (in a milder form) into std docs. Printing and producing errors is something that even non-expert users do frequently, so it is useful to give at least some indication of what a typical error message looks like.
2021-03-04Add tracking issue for map_try_insert.Mara Bos-2/+2
2021-03-04Implement Error for OccupiedError.Mara Bos-0/+18
2021-02-22Add impl `Error` for `Arc`Richard Dodd-0/+22
2021-01-24Rollup merge of #75180 - KodrAus:feat/error-by-ref, r=m-ou-seJonas Schievink-0/+21
Implement Error for &(impl Error) Opening this up just to see what it breaks. It's unfortunate that `&(impl Error)` doesn't actually implement `Error`. If this direct approach doesn't work out then I'll try something different, like an `Error::by_ref` method. **EDIT:** This is a super low-priority experiment so feel free to cancel it for more important crater runs! 🙂 ----- # Stabilization Report ## Why? We've been working for the last few years to try "fix" the `Error` trait, which is probably one of the most fundamental in the whole standard library. One of its issues is that we commonly expect you to work with abstract errors through `dyn Trait`, but references and smart pointers over `dyn Trait` don't actually implement the `Error` trait. If you have a `&dyn Error` or a `Box<dyn Error>` you simply can't pass it to a method that wants a `impl Error`. ## What does this do? This stabilizes the following trait impl: ```rust impl<'a, T: Error + ?Sized + 'static> Error for &'a T; ``` This means that `&dyn Error` will now satisfy a `impl Error` bound. It doesn't do anything with `Box<dyn Error>` directly. We discussed how we could do `Box<dyn Error>` in the thread here (and elsewhere in the past), but it seems like we need something like lattice-based specialization or a sprinkling of snowflake compiler magic to make that work. Having said that, with this new impl you _can_ now get a `impl Error` from a `Box<dyn Error>` by dereferencing it. ## What breaks? A crater run revealed a few crates broke with something like the following: ```rust // where e: &'short &'long dyn Error err.source() ``` previously we'd auto-deref that `&'short &'long dyn Error` to return a `Option<&'long dyn Error>` from `source`, but now will call directly on `&'short impl Error`, so will return a `Option<&'short dyn Error>`. The fix is to manually deref: ```rust // where e: &'short &'long dyn Error (*err).source() ``` In the recent Libs meeting we considered this acceptable breakage.
2020-12-31Remove many unnecessary manual link resolves from libraryCamelid-2/+0
Now that #76934 has merged, we can remove a lot of these! E.g, this is no longer necessary: [`Vec<T>`]: Vec
2020-12-21bump stabilization to 1.51.0Ashley Mannix-1/+1
2020-10-31update stabilization to 1.49.0Ashley Mannix-1/+1
2020-10-08Rename LayoutErr to LayoutError outside of coreJacob Hughes-2/+2
2020-09-28Rename AllocErr to AllocErrorJacob Hughes-2/+2
2020-09-11Mark Error impl for LayoutErr as stable.Mara Bos-5/+1
This impl was effectively stable. #[unstable] had no effect here, since both Error and LayoutErr were already stable. This effectively became stable as soon as LayoutErr became stable, which was in 1.28.0.
2020-08-31std: move "mod tests/benches" to separate filesLzu Tao-41/+3
Also doing fmt inplace as requested.
2020-08-27Reduce duplicate doc link in errorIvan Tham-1/+1
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-26Use [xxx()] rather than the [xxx] functionIvan Tham-2/+2
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-26Error use explicit intra-doc link and fix textIvan Tham-10/+7
2020-08-23Convert str -> prim@str in `std`Joshua Nelson-0/+4
2020-08-17Switch to intra-doc links for std/src/error.rsEllen-25/+3
2020-08-05implement Error for &(impl Error)Ashley Mannix-0/+21
2020-07-27mv std libs to library/mark-0/+802