From 8ad0645be7c26b3888cdbac6969a59eca188478c Mon Sep 17 00:00:00 2001 From: David Rajchenbach-Teller Date: Tue, 14 Aug 2012 19:56:47 -0400 Subject: [PATCH] Bug 773643 - Serialize Unix errors. r=froydnj --- .../osfile/osfile_unix_allthreads.jsm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/toolkit/components/osfile/osfile_unix_allthreads.jsm b/toolkit/components/osfile/osfile_unix_allthreads.jsm index 9878eb196d44..ef2120b08eb9 100644 --- a/toolkit/components/osfile/osfile_unix_allthreads.jsm +++ b/toolkit/components/osfile/osfile_unix_allthreads.jsm @@ -122,6 +122,24 @@ if (typeof Components != "undefined") { } }); + /** + * Serialize an instance of OSError to something that can be + * transmitted across threads (not necessarily a string). + */ + OSError.toMsg = function toMsg(error) { + return { + operation: error.operation, + unixErrno: error.unixErrno + }; + }; + + /** + * Deserialize a message back to an instance of OSError + */ + OSError.fromMsg = function fromMsg(msg) { + return new OSError(msg.operation, msg.unixErrno); + }; + exports.OS.Shared.Unix.Error = OSError; // Special constants that need to be defined on all platforms