feat(types): Add gRPC Richer Error Model support (BadRequest) (#1068)
* types: add tonic as dependency, add error_details.proto * types: add BadRequest support from flemosr/tonic-richer-error * types: adjust code following suggestions Adjustments following suggestions by @LucioFranco in https://github.com/hyperium/tonic/pull/1068. Adjust style, remove unecessary prints, avoid glob imports, apply `non_exhaustive` to `ErrorDetails` and `ErrorDetail`, avoid pub fields in `ErrorDetails`, adjust `WithErrorDetails::with_error_details_vec` args, add `gen_details_bytes`. * types: add generated protobuf code As suggested by @LucioFranco in https://github.com/hyperium/tonic/pull/1068#discussion_r956117520. This avoids the need for consumers to have `protoc` in their path. Implemented following changes in https://github.com/hyperium/tonic/pull/1065. * types: add custom metadata support This allows consumers to provide custom metadata when creating a `Status` with error details. * types: adjust code following suggestions Adjustments following suggestions by @LucioFranco in https://github.com/hyperium/tonic/pull/1068. Move `error_details_vec` mod into `error_details` mod, adjust doc comments, rename `WithErrorDetails` trait to `StatusExt`.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
use std::{path::PathBuf, process::Command};
|
||||
|
||||
#[test]
|
||||
fn bootstrap() {
|
||||
let iface_files = &["proto/status.proto", "proto/error_details.proto"];
|
||||
let dirs = &["proto"];
|
||||
|
||||
let out_dir = PathBuf::from(std::env!("CARGO_MANIFEST_DIR"))
|
||||
.join("src")
|
||||
.join("generated");
|
||||
|
||||
tonic_build::configure()
|
||||
.out_dir(format!("{}", out_dir.display()))
|
||||
.compile(iface_files, dirs)
|
||||
.unwrap();
|
||||
|
||||
let status = Command::new("git")
|
||||
.arg("diff")
|
||||
.arg("--exit-code")
|
||||
.arg("--")
|
||||
.arg(format!("{}", out_dir.display()))
|
||||
.status()
|
||||
.unwrap();
|
||||
|
||||
if !status.success() {
|
||||
panic!("You should commit the protobuf files");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user