// Partial Copyright Jerome Benoit. 2021-2024. All Rights Reserved.
import { BaseError } from './BaseError.js'
-import {
- type ErrorType,
- type IncomingRequestCommand,
- type JsonType,
- type RequestCommand
-} from '../types/index.js'
+import type { ErrorType, IncomingRequestCommand, JsonType, RequestCommand } from '../types/index.js'
import { Constants } from '../utils/index.js'
export class OCPPError extends BaseError {
code: ErrorType
- command?: RequestCommand | IncomingRequestCommand
+ command: RequestCommand | IncomingRequestCommand
details?: JsonType
constructor (
--- /dev/null
+import { describe, it } from 'node:test'
+
+import { expect } from 'expect'
+
+import { BaseError } from '../../src/exception/BaseError.js'
+
+await describe('BaseError test suite', async () => {
+ await it('Verify that BaseError can be instantiated', () => {
+ const baseError = new BaseError()
+ expect(baseError).toBeInstanceOf(BaseError)
+ expect(baseError.name).toBe('BaseError')
+ expect(baseError.message).toBe('')
+ expect(typeof baseError.stack === 'string').toBe(true)
+ expect(baseError.stack).not.toBe('')
+ expect(baseError.cause).toBeUndefined()
+ expect(baseError.date).toBeInstanceOf(Date)
+ })
+
+ await it('Verify that BaseError can be instantiated with a message', () => {
+ const baseError = new BaseError('Test message')
+ expect(baseError).toBeInstanceOf(BaseError)
+ expect(baseError.message).toBe('Test message')
+ })
+})