Expose Lib-specific Error Ctor
harrysolovay opened this issue · 0 comments
harrysolovay commented
Thoughts on exposing a lib-specific error? Would allow us to catch SCALE-specific errors with an instanceof
check.
import * as $ from "https://deno.land/x/scale/mod.ts";
try {
$.object(
["name", $.str],
["nickName", $.str],
["superPower", $.option($.str)],
).encode(1618 as any);
} catch(e) {
if (e instanceof $.ScaleError) {
e;
}
}
Not sure what fields we may want to attach to e
(if any). It'd be nice if we could attach state/cues to help debugging.