Skip to content

Commit 3b36cb6

Browse files
committed
Detailed error codes
1 parent 3355ccc commit 3b36cb6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

boring/src/error.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@ impl Error {
182182
}
183183
}
184184

185+
/// Returns the raw OpenSSL error constant for the library reporting the
186+
/// error.
187+
pub fn library_code(&self) -> libc::c_int {
188+
ffi::ERR_GET_LIB(self.code)
189+
}
190+
185191
/// Returns the name of the function reporting the error.
186192
pub fn function(&self) -> Option<&'static str> {
187193
unsafe {
@@ -206,6 +212,11 @@ impl Error {
206212
}
207213
}
208214

215+
/// Returns the raw OpenSSL error constant for the reason for the error.
216+
pub fn reason_code(&self) -> libc::c_int {
217+
ffi::ERR_GET_REASON(self.code)
218+
}
219+
209220
/// Returns the name of the source file which encountered the error.
210221
pub fn file(&self) -> &'static str {
211222
unsafe {
@@ -235,12 +246,14 @@ impl fmt::Debug for Error {
235246
if let Some(library) = self.library() {
236247
builder.field("library", &library);
237248
}
249+
builder.field("library_code", &self.library_code());
238250
if let Some(function) = self.function() {
239251
builder.field("function", &function);
240252
}
241253
if let Some(reason) = self.reason() {
242254
builder.field("reason", &reason);
243255
}
256+
builder.field("reason_code", &self.reason_code());
244257
builder.field("file", &self.file());
245258
builder.field("line", &self.line());
246259
if let Some(data) = self.data() {

0 commit comments

Comments
 (0)