-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
syntax error message made more verbose #1462
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -815,8 +815,19 @@ | |
const results = []; | ||
for (const file of files) { | ||
const content = await this._getData(file, new TextWriter()); | ||
/** @type {unknown} */ | ||
const entries = parseJson(content); | ||
let entries; | ||
|
||
try { | ||
/** @type {unknown} */ | ||
entries = parseJson(content); | ||
} | ||
catch (error) { | ||
if (error instanceof Error) { | ||
let newError = new Error(error.message + `. Dictionary has invalid data in '${file.filename}'`); | ||
console.error(newError); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In addition, I don't think it's useful logging here and still letting the error propagate. If I decided to log the errors upstream, it would cause the error to be logged twice. You can remove the console.error entirely. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. I'll do away with it entirely. |
||
throw newError; | ||
} | ||
} | ||
|
||
startIndex = progressData.index; | ||
this._progress(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use
log.error
instead.log
is a wrapper aroundconsole
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. Can you elaborate on what makes log.error more appropriate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can check out https://github.com/themoeway/yomitan/blob/master/ext/js/core/log.js#L74. It basically formats the log with info for the extension.