-
Notifications
You must be signed in to change notification settings - Fork 1.7k
improve: error handling for scripts #4082
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
improve: error handling for scripts #4082
Conversation
packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js
Outdated
Show resolved
Hide resolved
packages/bruno-app/src/components/RequestPane/HttpRequestPane/index.js
Outdated
Show resolved
Hide resolved
} | ||
|
||
// Run JSHint with predefined Bruno globals | ||
if (!window.JSHINT(text, { |
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.
this could be defined as a const
const JS_LINT_OPTIONS = {
esversion: 11,
expr: true,
asi: true,
undef: true,
browser: true,
devel: true,
predef: {
'bru': false,
'req': false,
'res': false
}
}
also other keywords like test
and expect
need to predef
@@ -357,7 +410,23 @@ export default class CodeEditor extends React.Component { | |||
|
|||
_onEdit = () => { | |||
if (!this.ignoreChangeEvent && this.editor) { | |||
this.editor.setOption('lint', this.editor.getValue().trim().length > 0 ? this.lintOptions : false); | |||
if (this.props.mode === 'javascript') { |
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.
the lint options could be defined once in the constructor based on mode and used everywhere
@@ -731,38 +766,38 @@ const registerNetworkIpc = (mainWindow) => { | |||
|
|||
const testFile = get(request, 'tests'); | |||
if (typeof testFile === 'string') { | |||
const testRuntime = new TestRuntime({ runtime: scriptingConfig?.runtime }); |
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.
nothing got modified here except indentation ?
); | ||
} catch (error) { | ||
console.error('Post-response script error:', error); | ||
postResponseError = serializeError(error); |
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.
could be a new different event like request-post-script-error
or something
Description
Improved Error Handling for Request Scripts
What Changed
scriptErrors
field in the response object to track both post-response error