Closed Bug 302063 Opened 20 years ago Closed 12 years ago

Improve string API for error handling

Categories

(Core :: XPCOM, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: darin.moz, Unassigned)

Details

(Keywords: helpwanted)

The string API makes error handling for things like out-of-memory difficult and tedious. The API encourages people not to do error checking, which can lead to problems. This is particularly the case when code uses BeginWriting to get mutable access to the string's internal buffer. People tend to write code that calls SetLength followed by BeginWriting without checking that SetLength succeeded. The only way to do so is to call Length before calling BeginWriting. Another example is using Replace to modify the string. It may be awkward to compute what the length of the string should be after calling Replace, and so people may avoid error checking. This is somewhat related to bug 284219.
Keywords: helpwanted
We've done this by making the API infallible by default.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → WORKSFORME
Component: String → XPCOM
You need to log in before you can comment on or make changes to this bug.