Files
speckle-server/packages/server/test/speckle-helpers/error.ts
T
Kristaps Fabians Geikins 51579b76ef fix(server): various fixes related to subs + further improved utils + way quicker tests (#3573)
* fixed test util throwing + added new tests

* more tests

* more tests

* various model tests

* version tests

* removed shitty old tests

* lint fix

* workspaceProjectsUpdated test

* workspace updated on invite

* workspace subs support team changes

* tests fix

* test fix hopefully?
2024-12-02 13:30:24 +02:00

25 lines
642 B
TypeScript

import { BaseError } from '@/modules/shared/errors'
import { VError } from 'verror'
/**
* Generic VError-enhanced error for usage in tests
*/
export class TestError extends BaseError {
static code = 'TEST_ERROR'
static message = 'Error occurred in a test'
}
/**
* Ensure VError.cause & info are reported properly in stack trace
*/
export const fixStackTrace = (err: unknown) => {
if (err instanceof BaseError) {
const info = VError.info(err)
const hasInfo = Object.keys(info).length > 0
err.stack = `${VError.fullStack(err)}${
hasInfo ? '\nInfo:\n' + JSON.stringify(info, undefined, 4) + '\n' : ''
}`
}
}