ledger_models/fintekkers.requests.util.errors.rs
1#[allow(clippy::derive_partial_eq_without_eq)]
2#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct Message {
4 /// This message should not have any technical knowledge requirements to be understood
5 /// and provide a suggested action for how to avoid. Examples:
6 ///
7 /// A server throws an exception -> "Please retry your operation, and if it fails again,
8 /// contact customer support".
9 ///
10 /// A bond security is set as having a fixed coupon, but a reference index and spread is
11 /// provided -> "A fixed income bond needs a static coupon, and shouldn't have an index
12 /// or spread provided."
13 #[prost(string, tag = "1")]
14 pub message_for_user: ::prost::alloc::string::String,
15 /// This message can be used to instruct a developer operating on APIs how best to approach
16 /// resolving this issue.
17 /// A server throws an exception -> "The <x> service timed out or rejected this message.
18 /// Please consider whether you are spamming the backend server and reach out to developer
19 /// support to see how to optimize your usage".
20 #[prost(string, tag = "2")]
21 pub message_for_developer: ::prost::alloc::string::String,
22}
23/// One field-level input problem found by a ledger-models validator (e.g. a bond with
24/// no face_value). Validators return these so a service can put them as-is into
25/// ErrorProto.violations and answer with gRPC INVALID_ARGUMENT.
26///
27/// Violations describe bad input only. State errors that depend on what a service
28/// already holds (e.g. no lots to reduce, duplicates, permissions) never use this
29/// message; services report those as FAILED_PRECONDITION or similar.
30#[allow(clippy::derive_partial_eq_without_eq)]
31#[derive(Clone, PartialEq, ::prost::Message)]
32pub struct FieldViolationProto {
33 /// Proto field path of the bad field, snake_case, relative to the top-level object
34 /// that was validated. Nested fields are dot-separated, e.g. "bond_details.face_value"
35 /// when validating a security, or "security.bond_details.face_value" when the same
36 /// security is validated as part of a transaction.
37 #[prost(string, tag = "1")]
38 pub field: ::prost::alloc::string::String,
39 /// UUID of the object that owns the bad field: the security for bond rules, even when
40 /// the violation was found by validating a transaction. Unset if the input had no UUID.
41 #[prost(message, optional, tag = "2")]
42 pub object_id: ::core::option::Option<super::super::super::models::util::UuidProto>,
43 /// Human-readable English explanation for a developer. Not stable; do not parse it.
44 #[prost(string, tag = "3")]
45 pub message: ::prost::alloc::string::String,
46}
47/// An error is used for situations where a request cannot be processed successfully, either
48/// from a technical perspective or a business perspective.
49#[allow(clippy::derive_partial_eq_without_eq)]
50#[derive(Clone, PartialEq, ::prost::Message)]
51pub struct ErrorProto {
52 #[prost(enumeration = "ErrorCode", tag = "1")]
53 pub code: i32,
54 #[prost(message, optional, tag = "2")]
55 pub detail: ::core::option::Option<Message>,
56 /// Field-level input problems behind this error, one per bad field, as returned by
57 /// the ledger-models validators. Empty for errors that are not about bad input
58 /// (e.g. state errors such as no lots to reduce).
59 #[prost(message, repeated, tag = "3")]
60 pub violations: ::prost::alloc::vec::Vec<FieldViolationProto>,
61}
62/// Warnings can have error codes, if it is useful in categorizing the severity of the warning.
63/// For example a warning may be thrown if 2 securities are created with the same identifier.
64/// Another example may be usage of a deprecated API.
65#[allow(clippy::derive_partial_eq_without_eq)]
66#[derive(Clone, PartialEq, ::prost::Message)]
67pub struct WarningProto {
68 #[prost(enumeration = "ErrorCode", tag = "1")]
69 pub code: i32,
70 #[prost(message, optional, tag = "2")]
71 pub detail: ::core::option::Option<Message>,
72}
73/// Error codes are defined to allow clients to programmatically
74/// respond to issues. The bar for creating a new error code should
75/// be that the
76#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
77#[repr(i32)]
78pub enum ErrorCode {
79 UnknownError = 0,
80 /// TO THINK ABOUT
81 Warning = 1,
82}
83impl ErrorCode {
84 /// String value of the enum field names used in the ProtoBuf definition.
85 ///
86 /// The values are not transformed in any way and thus are considered stable
87 /// (if the ProtoBuf definition does not change) and safe for programmatic use.
88 pub fn as_str_name(&self) -> &'static str {
89 match self {
90 ErrorCode::UnknownError => "UNKNOWN_ERROR",
91 ErrorCode::Warning => "WARNING",
92 }
93 }
94 /// Creates an enum from field names used in the ProtoBuf definition.
95 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
96 match value {
97 "UNKNOWN_ERROR" => Some(Self::UnknownError),
98 "WARNING" => Some(Self::Warning),
99 _ => None,
100 }
101 }
102}
103/// GRPC error codes are used to indicate if there was any substantial issue. They cover situations
104/// like OK, Cancelled, AlreadyExists, InvalidArgument, ResourceExhausted, Unauthenticated, etc.
105/// Ideally Fintekkers will not introduce another concept on top of that to avoid complicating the
106/// solution.
107///
108/// If there are any errors, the GRPC response should not return OK (code=0).
109/// Warnings may be returned at any time, and may be done even with successful responses.
110#[allow(clippy::derive_partial_eq_without_eq)]
111#[derive(Clone, PartialEq, ::prost::Message)]
112pub struct SummaryProto {
113 #[prost(message, repeated, tag = "1")]
114 pub errors: ::prost::alloc::vec::Vec<ErrorProto>,
115 #[prost(message, repeated, tag = "2")]
116 pub warnings: ::prost::alloc::vec::Vec<WarningProto>,
117}