Closed Bug 760448 Opened 12 years ago Closed 12 years ago

Propagate error in CommonUtils.jsonSave

Categories

(Cloud Services :: Firefox: Common, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla15

People

(Reporter: gps, Assigned: gps)

References

Details

Attachments

(1 file)

Attached patch send result to callback, v1 (deleted) — Splinter Review
CommonUtils.jsonSave doesn't tell the callback whether the save actually worked. This patch changes that. I have no idea how to actually get an error code to get raised. I can pass bad arguments to jsonSave, but those will result in exceptions at call time. Making things fail reliably during the async saving is, um, I dunno. This patch will shave ~60 lines from AITC's storage module so it doesn't have to reimplement JSON I/O. Reuse FTW.
Attachment #629184 - Flags: review?(rnewman)
Comment on attachment 629184 [details] [diff] [review] send result to callback, v1 Review of attachment 629184 [details] [diff] [review]: ----------------------------------------------------------------- ::: services/common/tests/unit/test_utils_json.js @@ +11,5 @@ > > add_test(function test_roundtrip() { > _("Do a simple write of an array to json and read"); > + CommonUtils.jsonSave("foo", {}, ["v1", "v2"], ensureThrows(function(error) { > + do_check_eq(error, null); Do we not have do_check_null? ::: services/common/utils.js @@ +409,5 @@ > if (typeof callback == "function") { > + let error = null; > + if (result != Cr.NS_OK) { > + error = result; > + } let error = (result == Cr.NS_OK) ? null : result; would do fine for me.
Attachment #629184 - Flags: review?(rnewman) → review+
I thought you didn't like the ternary operator. Someone doesn't like it...
Assignee: nobody → gps
Status: NEW → ASSIGNED
Whiteboard: [fixed in services]
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Whiteboard: [fixed in services]
Target Milestone: --- → mozilla15
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: