• 1.8K Posts
  • 1.46K 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.












  • Der einzelne Sparplan bewegt den Kurs von Apple nicht messbar, aber die kollektive Nachfrage von Millionen Anlegern, die in dieselben Indizes investieren, bleibt nicht folgenlos.

    Nein, ich denke auch Millionen von Index-ETF Anlegern haben praktisch keinen Effekt auf den Apple Kurs.

    Es ist reine Symptombekämpfung. Es gilt den Bedarf nach US Big Tech Produkten zu reduzieren. Dann werden die Index-ETFs auch automatisch weniger von denen kaufen, weil deren Kurs/Anteil sinkt.