Add a few TypeDoc annotations for CameraError

This commit is contained in:
mrousavy 2021-03-07 14:26:21 +01:00
parent d4b8da790c
commit bfcb6b37d8

View File

@ -104,6 +104,9 @@ class CameraError<TCode extends CameraErrorCode> extends Error {
return this._cause; return this._cause;
} }
/**
* @internal
*/
constructor(code: TCode, message: string, cause?: ErrorWithCause) { constructor(code: TCode, message: string, cause?: ErrorWithCause) {
super(`[${code}]: ${message}${cause ? ` (Cause: ${cause.message})` : ''}`); super(`[${code}]: ${message}${cause ? ` (Cause: ${cause.message})` : ''}`);
this._code = code; this._code = code;
@ -124,6 +127,11 @@ export class CameraRuntimeError extends CameraError<
PermissionError | ParameterError | DeviceError | FormatError | SessionError | SystemError | UnknownError PermissionError | ParameterError | DeviceError | FormatError | SessionError | SystemError | UnknownError
> {} > {}
/**
* Checks if the given `error` is of type `ErrorWithCause`
* @param error Any unknown object to validate
* @returns `true` if the given `error` is of type `ErrorWithCause`
*/
export const isErrorWithCause = (error: unknown): error is ErrorWithCause => export const isErrorWithCause = (error: unknown): error is ErrorWithCause =>
typeof error === 'object' && typeof error === 'object' &&
error != null && error != null &&