fix: added logging for parser errors

This commit is contained in:
Kacper Kula 2025-01-27 09:42:37 +00:00
parent f38bae13e9
commit 320e7b76c1
4 changed files with 24 additions and 6 deletions

View file

@ -1,3 +1,6 @@
# 0.19.1 (2025-01-27)
Added logging for unprocessable data to help reporting.
# 0.19.0 (2025-01-24)
Adding support for JSON and JSON5 files. You can now query these data types and create tables based on them. You can use JSONPath to traverse the JSON files and extract data from it. [See more in the documentation](http://hypersphere.blog/sql-seal/data-sources/json-and-json5.html).

View file

@ -1,6 +1,6 @@
{
"name": "sqlseal",
"version": "0.19.0",
"version": "0.19.1",
"description": "A plugin for Obsidian that allows you to run SQL queries on your notes.",
"main": "main.js",
"scripts": {

View file

@ -11,11 +11,19 @@ export const displayError= (el: HTMLElement, text: string) => {
}
export const parseCell = (data: string, app: App) => {
if (data && typeof data === 'string' && data.startsWith('SQLSEALCUSTOM')) {
const parsedData = JSON.parse(data.slice('SQLSEALCUSTOM('.length, -1))
return renderSqlSealCustomElement(parsedData, app)
}
return data
try {
if (data && typeof data === 'string' && data.startsWith('SQLSEALCUSTOM')) {
const parsedData = JSON.parse(data.slice('SQLSEALCUSTOM('.length, -1))
return renderSqlSealCustomElement(parsedData, app)
}
return data
} catch (e) {
console.error('Error parsing cell with data:', data, e)
return createDiv({
text: 'Parsing error',
cls: 'sqlseal-parse-error'
})
}
}
type SqlSealAnchorElement = {

View file

@ -133,4 +133,11 @@
.sqlseal-list.show-column-names .sqlseal-list-element-single .sqlseal-column-name {
display: inline;
}
.sqlseal-parse-error {
background: #b80f0f;
color: #FFF;
padding: 0.2em;
border-radius: 2px;
}