From 5068d34c08f951a7ea6257d305a1627b09a95817 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 19:44:55 +0200 Subject: Adding upstream version 0.11.1. Signed-off-by: Daniel Baumann --- docs/_posts/2022-08-04-pretty-errors.md | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 docs/_posts/2022-08-04-pretty-errors.md (limited to 'docs/_posts/2022-08-04-pretty-errors.md') diff --git a/docs/_posts/2022-08-04-pretty-errors.md b/docs/_posts/2022-08-04-pretty-errors.md new file mode 100644 index 0000000..b04c9e8 --- /dev/null +++ b/docs/_posts/2022-08-04-pretty-errors.md @@ -0,0 +1,46 @@ +--- +layout: post +title: Pretty error messages +excerpt: Error message improvements +--- + +*(This change will be in the upcoming v0.11.0 release)* + +Taking a page from compilers like rustc, I've spent some time +improving error messages to make them look nicer and be more +helpful. Fortunately, SQLite has improved their error reporting +as well by adding +[sqlite3_error_offset()](http://sqlite.com/c3ref/errcode.html). +This function can point to the part of the SQL statement that +was in error. As an example of the improvement, a SQL file +that contained the following content: + +```sql + +-- This is a test +SELECT abc), +rtrim(def) +FROM mytable; +``` + +Would report an error like the following on startup in v0.10.1: + +```text +error:/Users/tstack/.config/lnav/formats/installed/test.sql:2:near ")": syntax error +``` + +Now, you will get a clearer error message with a syntax-highlighted +code snippet and a pointer to the part of the code that has the +problem: + +![Screenshot of a SQL error](/assets/images/lnav-sql-error-msg.png) + +Inside the TUI, a panel has been added at the bottom to display these +long-form error messages. The panel will disappear after a short +time or when input is received. Here is an example showing an error +for an invalid regular expression: + + -- cgit v1.2.3