Merge pull request #54 from h-sphere/fix/parsing-errors

fix: added logging for parser errors
This commit is contained in:
Kacper Kula 2025-01-27 09:45:49 +00:00 committed by GitHub
commit e9bee3d329
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 27 additions and 8 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,7 +1,7 @@
{
"id": "sqlseal",
"name": "SQLSeal",
"version": "0.19.0",
"version": "0.19.1",
"minAppVersion": "0.15.0",
"description": "Use SQL in your notes to query your vault files and CSV content.",
"author": "hypersphere",

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;
}

View file

@ -28,5 +28,6 @@
"0.17.0": "0.15.0",
"0.18.0": "0.15.0",
"0.18.1": "0.15.0",
"0.19.0": "0.15.0"
"0.19.0": "0.15.0",
"0.19.1": "0.15.0"
}