aglinxinyuan opened a new issue, #6254:
URL: https://github.com/apache/texera/issues/6254
### Task Summary
Add `error.spec.ts` covering `extractErrorMessage`, the helper that
normalizes an error of unknown shape into a display string.
## Background
`frontend/src/app/common/util/error.ts` exports a single pure function used
across the UI to turn a thrown/backend error into a user-facing string. It has
four distinct branches and no test.
```ts
export function extractErrorMessage(err: unknown): string {
if (err instanceof Error) return err.message;
if (typeof err === "object" && err !== null && "error" in err) {
const backendErr = (err as any).error;
if (typeof backendErr === "string") return backendErr;
if (typeof backendErr === "object" && "message" in backendErr) return
backendErr.message;
}
return "An unknown error occurred.";
}
```
## Behavior to pin
| Input | Result |
| --- | --- |
| an `Error` instance | its `.message` |
| `{ error: "boom" }` (string `error`) | `"boom"` |
| `{ error: { message: "nested" } }` | `"nested"` |
| `null`, a number, `{}`, `{ error: 123 }` | `"An unknown error occurred."` |
Follow `size-formatter.util.spec.ts` in `common/util/` as the style template
(plain `describe`/`it`/`expect`, run with `ng test`).
## Scope
- New spec: `frontend/src/app/common/util/error.spec.ts`.
- No production-code changes.
### Task Type
- [ ] Refactor / Cleanup
- [ ] DevOps / Deployment / CI
- [x] Testing / QA
- [ ] Documentation
- [ ] Performance
- [ ] Other
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]