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/// An error is used for situations where a request cannot be processed successfully, either
24/// from a technical perspective or a business perspective.
25#[allow(clippy::derive_partial_eq_without_eq)]
26#[derive(Clone, PartialEq, ::prost::Message)]
27pub struct ErrorProto {
28 #[prost(enumeration = "ErrorCode", tag = "1")]
29 pub code: i32,
30 #[prost(message, optional, tag = "2")]
31 pub detail: ::core::option::Option<Message>,
32}
33/// Warnings can have error codes, if it is useful in categorizing the severity of the warning.
34/// For example a warning may be thrown if 2 securities are created with the same identifier.
35/// Another example may be usage of a deprecated API.
36#[allow(clippy::derive_partial_eq_without_eq)]
37#[derive(Clone, PartialEq, ::prost::Message)]
38pub struct WarningProto {
39 #[prost(enumeration = "ErrorCode", tag = "1")]
40 pub code: i32,
41 #[prost(message, optional, tag = "2")]
42 pub detail: ::core::option::Option<Message>,
43}
44/// Error codes are defined to allow clients to programmatically
45/// respond to issues. The bar for creating a new error code should
46/// be that the
47#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
48#[repr(i32)]
49pub enum ErrorCode {
50 UnknownError = 0,
51 /// TO THINK ABOUT
52 Warning = 1,
53}
54impl ErrorCode {
55 /// String value of the enum field names used in the ProtoBuf definition.
56 ///
57 /// The values are not transformed in any way and thus are considered stable
58 /// (if the ProtoBuf definition does not change) and safe for programmatic use.
59 pub fn as_str_name(&self) -> &'static str {
60 match self {
61 ErrorCode::UnknownError => "UNKNOWN_ERROR",
62 ErrorCode::Warning => "WARNING",
63 }
64 }
65 /// Creates an enum from field names used in the ProtoBuf definition.
66 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
67 match value {
68 "UNKNOWN_ERROR" => Some(Self::UnknownError),
69 "WARNING" => Some(Self::Warning),
70 _ => None,
71 }
72 }
73}
74/// GRPC error codes are used to indicate if there was any substantial issue. They cover situations
75/// like OK, Cancelled, AlreadyExists, InvalidArgument, ResourceExhausted, Unauthenticated, etc.
76/// Ideally Fintekkers will not introduce another concept on top of that to avoid complicating the
77/// solution.
78///
79/// If there are any errors, the GRPC response should not return OK (code=0).
80/// Warnings may be returned at any time, and may be done even with successful responses.
81#[allow(clippy::derive_partial_eq_without_eq)]
82#[derive(Clone, PartialEq, ::prost::Message)]
83pub struct SummaryProto {
84 #[prost(message, repeated, tag = "1")]
85 pub errors: ::prost::alloc::vec::Vec<ErrorProto>,
86 #[prost(message, repeated, tag = "2")]
87 pub warnings: ::prost::alloc::vec::Vec<WarningProto>,
88}