Add naming_provider::Error type
commitdaf6dc34154c10dc7df7affb9bb204fd6ec0b00e
authorJake Bailey (Hacklang) <jakebailey@fb.com>
Fri, 25 Feb 2022 19:23:23 +0000 (25 11:23 -0800)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Fri, 25 Feb 2022 19:23:23 +0000 (25 11:23 -0800)
treedbb19b194d95dee7aa2695d54323969672ace6c2
parent4addad2201ffafe25c80f812151cd1b2bb043274
Add naming_provider::Error type

Summary:
Push .unwrap()s up a level by adding proper error handling in NamingProvider.

Some error-type boilerplate is derived by the [thiserror](https://docs.rs/thiserror/latest/thiserror/) crate.

The idea behind this design is that the Error type will contain variants for all possible implementations of NamingProvider. For instance, if we added an implementation of NamingProvider which has its own database implementation and directly interacts with the filesystem, we might add an `IoError(#[from] std::io::Error)` variant, even though a `SqliteNamingProvider` will never return it.

We can improve this type in the future by adding variants with higher-level meaning. For instance, if no file exists at the path of our SQLite database, we might return a new variant like:

```
    #[error("File not found: {path:?}")]
    DatabaseFileNotFound { path: PathBuf },
````

rather than a variant wrapping the (much-more-general) `rusqlite::Error` or `std::io::Error` types.

Reviewed By: shayne-fletcher

Differential Revision: D34461056

fbshipit-source-id: bb4b84dee2c7a162d5fa271d4a8dae4e08b1373a
hphp/hack/src/rupro/decl_file.rs
hphp/hack/src/rupro/lib/naming_provider.rs
hphp/hack/src/rupro/lib/shallow_decl_provider/provider.rs