static Exception GetException (MonoBtlsSslError status)
{
- var error = MonoBtlsError.GetError ();
+ string file;
+ int line;
+ var error = MonoBtlsError.GetError (out file, out line);
+ if (error == null)
+ return new MonoBtlsException (status);
+
var text = MonoBtlsError.GetErrorString (error);
- return new MonoBtlsException ("{0} {1}", status, text);
+
+ string message;
+ if (file != null)
+ message = string.Format ("{0} {1}\n at {2}:{3}", status, text, file, line);
+ else
+ message = string.Format ("{0} {1}", status, text);
+ return new MonoBtlsException (message);
}
public override bool ProcessHandshake ()
[DllImport (MonoBtlsObject.BTLS_DYLIB)]
extern static void mono_btls_error_clear_error ();
+ [DllImport (MonoBtlsObject.BTLS_DYLIB)]
+ extern static int mono_btls_error_peek_error_line (out IntPtr file, out int line);
+
+ [DllImport (MonoBtlsObject.BTLS_DYLIB)]
+ extern static int mono_btls_error_get_error_line (out IntPtr file, out int line);
+
[DllImport (MonoBtlsObject.BTLS_DYLIB)]
extern static void mono_btls_error_get_error_string_n (int error, IntPtr buf, int len);
Marshal.FreeHGlobal (buffer);
}
}
+
+ public static int PeekError (out string file, out int line)
+ {
+ IntPtr filePtr;
+ var error = mono_btls_error_peek_error_line (out filePtr, out line);
+ if (filePtr != IntPtr.Zero)
+ file = Marshal.PtrToStringAnsi (filePtr);
+ else
+ file = null;
+ return error;
+ }
+
+ public static int GetError (out string file, out int line)
+ {
+ IntPtr filePtr;
+ var error = mono_btls_error_get_error_line (out filePtr, out line);
+ if (filePtr != IntPtr.Zero)
+ file = Marshal.PtrToStringAnsi (filePtr);
+ else
+ file = null;
+ return error;
+ }
}
}
#endif
return ERR_get_error ();
}
+MONO_API int
+mono_btls_error_peek_error_line (const char **file, int *line)
+{
+ return ERR_peek_error_line (file, line);
+}
+
+MONO_API int
+mono_btls_error_get_error_line (const char **file, int *line)
+{
+ return ERR_get_error_line (file, line);
+}
+
MONO_API void
mono_btls_error_clear_error (void)
{
void
mono_btls_error_clear_error (void);
+int
+mono_btls_error_peek_error_line (const char **file, int *line);
+
+int
+mono_btls_error_get_error_line (const char **file, int *line);
+
void
mono_btls_error_get_error_string_n (int error, char *buf, int len);