• 9 Posts
  • 26 Comments
Joined 3 years ago
cake
Cake day: June 11th, 2023

help-circle
  • I just optimized the context messages and I’m now happy with:

    Error: Execute command: redo workspace/motd.json
    
    Caused by:
        0: using sqlite db 'workspace/.redo3.db'
        1: clear dependencies for motd.json
        2: attempt to write a readonly database
        3: Error code 8: attempt to write a readonly database
    

    The “0” context is especially important because it tells you which file is read-only. Here is the code for that:

    pub(crate) fn start(mut self) -> Result<DoFileExecution> {
        let rc_folder = self.target.path.parent().unwrap_or(Utf8Path::new("."));
        let mut db = Db::try_open(rc_folder);
        db.transaction(|tx| {
            tx.clear_dependencies(self.target.basename())
                .with_context(|| format!("using sqlite db '{}'", rc_folder.join(DB_FILENAME)))
        })?;
    
        let now = chrono::Utc::now();
        ...
    

    I don’t think something like “failed to clear dependencies using sqlite db ‘{}’” would be helpful. Something like “failed to” or “error when” does not really add any information. Just describe what is happening. Also, the “clear dependencies” would be redundant because that function can handle that part itself (see msg 1).


  • Since context is kind of on topic, what should one write there? Are there any principles for writing good context messages?

    fn beebboop() {
        foo();
        bar().context("frobnicating");
        baz();
    }
    

    Instead of “frobnicating” in this rough example, I could also write that we intend to “baz” afterwards or that we are “currently beebbooping” or “bar failed” or I could even mention “foo” or …

    From my (rather limited) experience, it seems most useful to describe what beebboop is about to do. Sometimes that is weird though, because then the context for foo, bar, and baz calls would be essentially the same.









  • Who said anything about “five nines”? All we know from the article:

    A couple of hundred claims a week would be a lot in normal times, he says. When the coronavirus hit, millions of claims suddenly were being filed and hitting the front end, which could not handle the massive increase in volume.

    I’d say it wouldn’t be that critical if was down half the time.

    Not sure of these “millions of claims” were submitted within days, weeks, or months. So we have no clue about the volume. Maybe a single server would be fine. But who am I kidding, the cheap Javascript guys will probably build a distributed cloud monster anyways…