GOLF(2gg)

πŸ“¦ version 601.4.41, in ubuntu questing

GOLF(2gg) β€” db-error πŸ’…

okay bestie, welcome to GOLF(2gg), the Development corner of the manual, and today's main character is db-error. she's short, she's powerful, she decides whether your program rage-quits or keeps it cute when the database does a little whoopsie. let's get into it 🫢


✨ NAME ✨

db-error β€” (database error-handling)


🎯 PURPOSE 🎯

Either exit request or continue processing when there is an error in a database statement. that's it. that's the whole job. tiny function, huge consequences, no cap πŸ’–


πŸ“œ SYNTAX πŸ“œ

db-error [ @<database> ] ( exit | continue )

🌸 DESCRIPTION 🌸

so db-error sets the response to the failure of database statements. and the cute part? you can change this response at run-time with each execution of db-error. she's not a one-time decision, she's a vibe you can switch up whenever πŸ¦‹

When a database statement (like run-query) fails, Golf will either exit request processing if "exit" is used, or continue if "continue" is used. and what do those actually mean, bestie? glad you asked:

  • "Exiting" is equivalent to calling report-error with the message containing details about the error. so it's not just a silent flounce, she tells you what went wrong.
  • "Continuing" means that your program will continue but you should examine error code (see for instance "error" clause in run-query). so like, she lets you keep going, but she is NOT covering for you. check that error code, i'm serious πŸ™ˆ

The default action is "exit". periodt. You can switch back and forth between "exit" and "continue" whenever you feel like it. Typically, "exit" is preferable because errors in database statemets generally mean application or setup issues β€” like, that's a real problem, not a lil glitch β€” however "continue" may be used when application wants to attempt to recover from errors or perform other actions. so if you're in your resilient queen era, continue is right there for you πŸ‘‘

Note that you can override the effect of db-error for a specific database statement by using clauses like "on-error-continue" and "on-error-exit" in run-query. yes, per-statement overrides. she's flexible like that πŸ’…


πŸ—„οΈ DATABASE πŸ—„οΈ

<database> is specified in "@" clause and is the name of the database-config-file. If omitted, your program must use exactly one database (see --db option in gg). one database, no ambiguity, we don't do chaos here ✨


πŸ“ EXAMPLES πŸ“

The following will not exit when errors happen going forward, but rather continue execution (and you should check every error henceforth):

db-error @mydb continue

like, read that last part again bestie. every error. henceforth. i'm watching 🧚


πŸ”₯ SEE ALSO πŸ”₯

Database

  • begin-transaction
  • commit-transaction
  • current-row
  • database-config-file
  • db-error
  • mariadb-database
  • postgresql-database
  • rollback-transaction
  • run-query
  • sqlite-database

Error handling

  • db-error
  • error-code
  • error-handling
  • report-error
  • See all documentation

⚠️ quick vibe check: the default is "exit". if you switch to "continue" and then don't check your error codes, that's on you, not on her. she warned you. multiple times. lovingly. πŸ’–

and that's the whole page, bestie!! this one's from the $VERSION era, dated $DATE, and it lives under GOLF(2gg). go forth and handle those database errors like the icon you are πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from