clean up js errors

This commit is contained in:
Orion Henry 2020-04-21 13:08:00 -07:00
parent eaa023e219
commit fa125e94c5
4 changed files with 7 additions and 12 deletions
automerge-backend-wasm
automerge-backend/src

View file

@ -77,13 +77,8 @@ function getRedoStack(backend) {
return backendState(backend).getRedoStack()
}
function decodeChange(backend,change) {
return backendState(backend).decodeChange(change)
}
module.exports = {
initCodecFunctions,
init, clone, free, applyChanges, applyLocalChange, loadChanges, getPatch,
getChanges, getChangesForActor, getMissingDeps, getUndoStack, getRedoStack,
decodeChange
}

View file

@ -142,9 +142,9 @@ impl State {
}
fn automerge_error_to_js(err: AutomergeError) -> JsValue {
JsValue::from(std::format!("Automerge error: {}", err))
js_sys::Error::new(&std::format!("Automerge error: {}", err)).into()
}
fn json_error_to_js(err: serde_json::Error) -> JsValue {
JsValue::from(std::format!("serde_json error: {}", err))
js_sys::Error::new(&std::format!("serde_json error: {}", err)).into()
}

View file

@ -316,12 +316,12 @@ impl<'a> Columns<'a> {
}
// FIXME - this could be an iterator (zip).map()
fn child(&mut self) -> Option<ObjectID> {
fn child(&mut self) -> Option<Option<ObjectID>> {
let actor = self.chld_actor.next()?;
let ctr = self.chld_ctr.next()?;
match (actor, ctr) {
(None, None) => Some(ObjectID::Root),
(Some(a), Some(c)) => Some(self.op_id(a, c)?.to_object_id()),
(None, None) => Some(None),
(Some(a), Some(c)) => Some(Some(self.op_id(a, c)?.to_object_id())),
_ => None,
}
}
@ -465,7 +465,7 @@ impl<'a> Columns<'a> {
return None;
}
}
Action::Link => OpType::Link(child),
Action::Link => OpType::Link(child?),
};
Some(Operation {
action,

View file

@ -12,7 +12,7 @@ fn err(s: &str) -> AutomergeError {
#[derive(Clone)]
pub(crate) struct Decoder<'a> {
pub offset: usize,
pub buf: &'a [u8],
buf: &'a [u8],
}
impl<'a> Decoder<'a> {