Skip to main content

canton_api_client/models/
js_canton_error.rs

1/*
2 * JSON Ledger API HTTP endpoints
3 *
4 * This specification version fixes the API inconsistencies where certain fields marked as required in the spec are in fact optional. If you use code generation tool based on this file, you might need to adjust the existing application code to handle those fields as optional. If you do not want to change your client code, continue using the OpenAPI specification from the previous Canton 3.4 patch release. MINIMUM_CANTON_VERSION=3.4.12
5 *
6 * The version of the OpenAPI document: 3.4.12-SNAPSHOT
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct JsCantonError {
16    #[serde(rename = "code")]
17    pub code: String,
18    #[serde(rename = "cause")]
19    pub cause: String,
20    #[serde(rename = "correlationId", skip_serializing_if = "Option::is_none")]
21    pub correlation_id: Option<String>,
22    #[serde(rename = "traceId", skip_serializing_if = "Option::is_none")]
23    pub trace_id: Option<String>,
24    #[serde(rename = "context")]
25    pub context: std::collections::HashMap<String, String>,
26    #[serde(rename = "resources", skip_serializing_if = "Option::is_none")]
27    pub resources: Option<Vec<Vec<String>>>,
28    #[serde(rename = "errorCategory")]
29    pub error_category: i32,
30    #[serde(rename = "grpcCodeValue", skip_serializing_if = "Option::is_none")]
31    pub grpc_code_value: Option<i32>,
32    #[serde(rename = "retryInfo", skip_serializing_if = "Option::is_none")]
33    pub retry_info: Option<String>,
34    #[serde(rename = "definiteAnswer", skip_serializing_if = "Option::is_none")]
35    pub definite_answer: Option<bool>,
36}
37
38impl JsCantonError {
39    pub fn new(code: String, cause: String, context: std::collections::HashMap<String, String>, error_category: i32) -> JsCantonError {
40        JsCantonError {
41            code,
42            cause,
43            correlation_id: None,
44            trace_id: None,
45            context,
46            resources: None,
47            error_category,
48            grpc_code_value: None,
49            retry_info: None,
50            definite_answer: None,
51        }
52    }
53}
54