refactor(http): moved #getErrorMessage to `@marblejs/core` module
MODIFY
packages/core/src/+internal/utils/error.util.ts
packages/core/src/+internal/utils/error.util.ts
+import { isString } from './string.util';
+
export class NamedError extends Error {
constructor(public name: string, message: string) {
super(message);
@@ -19,3 +21,10 @@ export const encodeError = (error: any) =>
}, Object.create(null));
export const throwException = (error: any) => { throw error; };
+
+export const getErrorMessage = (error: unknown): string =>
+ error instanceof Error
+ ? error.message
+ : isString(error)
+ ? error
+ : JSON.stringify(error);

MODIFY
packages/http/src/error/http.error.model.ts
packages/http/src/error/http.error.model.ts
import * as chalk from 'chalk';
import { CoreError, coreErrorFactory } from '@marblejs/core';
-import { isString, NamedError } from '@marblejs/core/dist/+internal/utils';
+import { NamedError } from '@marblejs/core/dist/+internal/utils';
import { HttpStatus, HttpRequest } from '../http.interface';
import { HttpEffectResponse } from '../effects/http.effects.interface';
@@ -53,10 +53,3 @@ export const errorNotBoundToRequestErrorFactory = (error: Error): CoreError => {
const message = `An effect or middleware thrown an error ${chalk.red(`"${error.message}"`)} without bound request.`;
return coreErrorFactory(message, { printStacktrace: false });
};
-
-export const getErrorMessage = (error: unknown): string =>
- error instanceof Error
- ? error.message
- : isString(error)
- ? error
- : JSON.stringify(error);

MODIFY
packages/http/src/router/http.router.resolver.ts
packages/http/src/router/http.router.resolver.ts
@@ -2,7 +2,7 @@ import { Observable, Subject, fromEvent, merge } from 'rxjs';
import { takeUntil, share, take, mergeMap, map, catchError } from 'rxjs/operators';
import { flow, pipe } from 'fp-ts/lib/function';
import { EffectContext, useContext, LoggerToken, LoggerTag, LoggerLevel } from '@marblejs/core';
-import { throwException } from '@marblejs/core/dist/+internal/utils';
+import { throwException, getErrorMessage } from '@marblejs/core/dist/+internal/utils';
import { HttpServer, HttpRequest, HttpStatus, WithHttpRequest } from '../http.interface';
import { defaultError$ } from '../error/http.error.effect';
import { HttpEffectResponse, HttpErrorEffect, HttpOutputEffect } from '../effects/http.effects.interface';
@@ -13,7 +13,6 @@ import {
isHttpRequestError,
HttpError,
isURIError,
- getErrorMessage
} from '../error/http.error.model';
import { HttpRequestBusToken } from '../server/internal-dependencies/httpRequestBus.reader';
import { requestMetadata$ } from '../effects/http.requestMetadata.effect';

refactor(http): moved #getErrorMessage to `@marblejs/core` module