Show save/execution error dialogs on desktop #264
This commit introduces system-native error dialogs on desktop application for code save or execution failures, addressing user confusion described in issue #264. This commit adds informative feedback when script execution or saving fails. Changes: - Implement support for system-native error dialogs. - Refactor `CodeRunner` and `Dialog` interfaces and their implementations to improve error handling and provide better type safety. - Introduce structured error handling, allowing UI to display detailed error messages. - Replace error throwing with an error object interface for controlled handling. This ensures that errors are propagated to the renderer process without being limited by Electron's error object serialization limitations as detailed in electron/electron#24427. - Add logging for dialog actions to aid in troubleshooting. - Rename `fileName` to `defaultFilename` in `saveFile` functions to clarify its purpose. - Centralize message assertion in `LoggerStub` for consistency. - Introduce `expectTrue` in tests for clearer boolean assertions. - Standardize `filename` usage across the codebase. - Enhance existing test names and organization for clarity. - Update related documentation.
This commit is contained in:
18
tests/shared/Assertions/ExpectTrue.ts
Normal file
18
tests/shared/Assertions/ExpectTrue.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Asserts that the provided boolean value is true.
|
||||
*
|
||||
* Useful when TypeScript's control flow analysis does not recognize standard
|
||||
* assertions, ensuring `value` is treated as true in subsequent code. This helps
|
||||
* prevent type errors and improves code safety and clarity. An optional custom
|
||||
* error message can be provided for more detailed assertion failures.
|
||||
*/
|
||||
export function expectTrue(value: boolean, errorMessage?: string): asserts value is true {
|
||||
if (value !== true) {
|
||||
throw new Error([
|
||||
`Assertion failed: Expected true, received ${value.toString()}.`,
|
||||
'Assertion failed: expected value is not true.',
|
||||
...(typeof value !== 'boolean' ? [`Received type: ${typeof value}`] : []),
|
||||
...(errorMessage ? [errorMessage] : []),
|
||||
].join('\n'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user