[Java] Print error stack trace when tests fail
[ldk-java] / src / main / java / org / ldk / structs / ErrorMessage.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * An [`error`] message to be sent to or received from a peer.
13  * 
14  * [`error`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class ErrorMessage extends CommonBase {
18         ErrorMessage(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.ErrorMessage_free(ptr); }
23         }
24
25         /**
26          * The channel ID involved in the error.
27          * 
28          * All-0s indicates a general error unrelated to a specific channel, after which all channels
29          * with the sending peer should be closed.
30          */
31         public ChannelId get_channel_id() {
32                 long ret = bindings.ErrorMessage_get_channel_id(this.ptr);
33                 Reference.reachabilityFence(this);
34                 if (ret >= 0 && ret <= 4096) { return null; }
35                 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
36                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
37                 return ret_hu_conv;
38         }
39
40         /**
41          * The channel ID involved in the error.
42          * 
43          * All-0s indicates a general error unrelated to a specific channel, after which all channels
44          * with the sending peer should be closed.
45          */
46         public void set_channel_id(org.ldk.structs.ChannelId val) {
47                 bindings.ErrorMessage_set_channel_id(this.ptr, val.ptr);
48                 Reference.reachabilityFence(this);
49                 Reference.reachabilityFence(val);
50                 if (this != null) { this.ptrs_to.add(val); };
51         }
52
53         /**
54          * A possibly human-readable error description.
55          * 
56          * The string should be sanitized before it is used (e.g., emitted to logs or printed to
57          * `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
58          * the terminal emulator or the logging subsystem.
59          */
60         public String get_data() {
61                 String ret = bindings.ErrorMessage_get_data(this.ptr);
62                 Reference.reachabilityFence(this);
63                 return ret;
64         }
65
66         /**
67          * A possibly human-readable error description.
68          * 
69          * The string should be sanitized before it is used (e.g., emitted to logs or printed to
70          * `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
71          * the terminal emulator or the logging subsystem.
72          */
73         public void set_data(java.lang.String val) {
74                 bindings.ErrorMessage_set_data(this.ptr, val);
75                 Reference.reachabilityFence(this);
76                 Reference.reachabilityFence(val);
77         }
78
79         /**
80          * Constructs a new ErrorMessage given each field
81          */
82         public static ErrorMessage of(org.ldk.structs.ChannelId channel_id_arg, java.lang.String data_arg) {
83                 long ret = bindings.ErrorMessage_new(channel_id_arg.ptr, data_arg);
84                 Reference.reachabilityFence(channel_id_arg);
85                 Reference.reachabilityFence(data_arg);
86                 if (ret >= 0 && ret <= 4096) { return null; }
87                 org.ldk.structs.ErrorMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ErrorMessage(null, ret); }
88                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
89                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_id_arg); };
90                 return ret_hu_conv;
91         }
92
93         long clone_ptr() {
94                 long ret = bindings.ErrorMessage_clone_ptr(this.ptr);
95                 Reference.reachabilityFence(this);
96                 return ret;
97         }
98
99         /**
100          * Creates a copy of the ErrorMessage
101          */
102         public ErrorMessage clone() {
103                 long ret = bindings.ErrorMessage_clone(this.ptr);
104                 Reference.reachabilityFence(this);
105                 if (ret >= 0 && ret <= 4096) { return null; }
106                 org.ldk.structs.ErrorMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ErrorMessage(null, ret); }
107                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
108                 return ret_hu_conv;
109         }
110
111         /**
112          * Generates a non-cryptographic 64-bit hash of the ErrorMessage.
113          */
114         public long hash() {
115                 long ret = bindings.ErrorMessage_hash(this.ptr);
116                 Reference.reachabilityFence(this);
117                 return ret;
118         }
119
120         @Override public int hashCode() {
121                 return (int)this.hash();
122         }
123         /**
124          * Checks if two ErrorMessages contain equal inner contents.
125          * This ignores pointers and is_owned flags and looks at the values in fields.
126          * Two objects with NULL inner values will be considered "equal" here.
127          */
128         public boolean eq(org.ldk.structs.ErrorMessage b) {
129                 boolean ret = bindings.ErrorMessage_eq(this.ptr, b.ptr);
130                 Reference.reachabilityFence(this);
131                 Reference.reachabilityFence(b);
132                 if (this != null) { this.ptrs_to.add(b); };
133                 return ret;
134         }
135
136         @Override public boolean equals(Object o) {
137                 if (!(o instanceof ErrorMessage)) return false;
138                 return this.eq((ErrorMessage)o);
139         }
140         /**
141          * Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
142          */
143         public byte[] write() {
144                 byte[] ret = bindings.ErrorMessage_write(this.ptr);
145                 Reference.reachabilityFence(this);
146                 return ret;
147         }
148
149         /**
150          * Read a ErrorMessage from a byte array, created by ErrorMessage_write
151          */
152         public static Result_ErrorMessageDecodeErrorZ read(byte[] ser) {
153                 long ret = bindings.ErrorMessage_read(ser);
154                 Reference.reachabilityFence(ser);
155                 if (ret >= 0 && ret <= 4096) { return null; }
156                 Result_ErrorMessageDecodeErrorZ ret_hu_conv = Result_ErrorMessageDecodeErrorZ.constr_from_ptr(ret);
157                 return ret_hu_conv;
158         }
159
160 }