about summary refs log tree commit diff
path: root/library/std/src/error.rs
AgeCommit message (Collapse)AuthorLines
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