CodeFaster

CodeFaster

Share this post

CodeFaster
CodeFaster
Log invalid values

Log invalid values

Tyler Adams's avatar
Tyler Adams
Nov 27, 2024
∙ Paid
1

Share this post

CodeFaster
CodeFaster
Log invalid values
Share

Gpt wrote some slop today:

if(!valid(value)) {
  console.log("Invalid value")
}

so people must be writing slop like that, let’s fix it:

CodeFaster is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.

if(!valid(value)) {
  console.log(`Invalid value:${value}`)
}

Isn’t that so much nicer! Now we can see in our logs what the value is. And it’s DSV so we can parse it with cut if we need the value (usually in my paste buffer but occasionally elsewhere).

Sometimes I’ll write a sick little:

./run | tail -n1 | cut -d : -f 2 | pbcopy

or if I log JSON

console.log(JSON.stringify({s: "Invalid value", value})

I can get the value via:

./run | tail -n1 | jq .value -r | pbcopy

isn’t fast programming fun?

CodeFaster is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.

This post is for paid subscribers

Already a paid subscriber? Sign in
© 2025 Tyler Adams
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share