firepear / petrel

It's like SQLite, but for networking
MIT License
20 stars 1 forks source link

Make error codes data #42

Closed firepear closed 8 years ago

firepear commented 8 years ago

Instead of explaining them in the doc, and having hardcoded numbers strewn about the place, make the error codes variables in the package.

firepear commented 8 years ago

Original plan was to send PERRPERR{error data} but JSON is unnecessarily heavy on processing and allocation. Will use :: to separate fields in error, as in PERRPERR402::error msg

firepear commented 8 years ago

Can use bytes.HasPrefix to test for response beginning with PERRPERR

firepear commented 8 years ago

Ditching the :: is possible because the format is invariable anyway. PERRPERRXXXMESSAGE

firepear commented 8 years ago

Several things need to happen.

firepear commented 8 years ago

Re: items 1 & 4 above, it might be good to leave the err, let it be nil in most cases, and assign to it in the cases where it's needed. Just have to reset it to nil after using it.

firepear commented 8 years ago

Can't make err a shared resource in the perrs. Race condition.

genMsg has to take 2 more arguments: a string containing whatever additional info might need to be made part of the Msg, and an error.

firepear commented 8 years ago

Once the client is updated, nothing needs to be sent except PERRPERRXXX

firepear commented 8 years ago

This work is done on the Server side. Client updates to come.

firepear commented 8 years ago

Client updated. New tests in.