@naturalcycles/js-lib
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -0,1 +1,8 @@ | ||
# [3.1.0](https://github.com/NaturalCycles/js-lib/compare/v3.0.0...v3.1.0) (2019-02-25) | ||
### Features | ||
* errorSharedUtil.errorObjectToHttpError, appErrorToHttpError ([f9cf571](https://github.com/NaturalCycles/js-lib/commit/f9cf571)) | ||
# [3.0.0](https://github.com/NaturalCycles/js-lib/compare/v2.2.2...v3.0.0) (2019-02-23) | ||
@@ -2,0 +9,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { AppError, objectUtil } from '..'; | ||
import { AppError, HttpError, objectUtil } from '..'; | ||
const EMPTY_STRING_MSG = 'empty_string'; | ||
@@ -43,2 +43,12 @@ class ErrorSharedUtil { | ||
} | ||
errorObjectToHttpError(o) { | ||
const err = Object.assign(new HttpError(o.message, o.data), { | ||
// name: err.name, // cannot be assigned to a readonly property like this | ||
stack: o.stack, | ||
}); | ||
Object.defineProperty(err, 'name', { | ||
value: o.name, | ||
}); | ||
return err; | ||
} | ||
appErrorToErrorObject(err) { | ||
@@ -52,4 +62,7 @@ return { | ||
} | ||
appErrorToHttpError(err) { | ||
return new HttpError(err.message, err.data); | ||
} | ||
} | ||
export const errorSharedUtil = new ErrorSharedUtil(); | ||
//# sourceMappingURL=error.shared.util.js.map |
@@ -63,1 +63,2 @@ import { StringMap } from '../types'; | ||
} | ||
export declare type HttpErrorResponse = ErrorResponse<HttpErrorData>; |
@@ -1,2 +0,2 @@ | ||
import { AppError } from '..'; | ||
import { AppError, HttpError, HttpErrorData } from '..'; | ||
import { ErrorObject } from '../error/error.model'; | ||
@@ -12,5 +12,7 @@ declare class ErrorSharedUtil { | ||
errorObjectToAppError<T>(o: ErrorObject<T>): AppError<T>; | ||
errorObjectToHttpError(o: ErrorObject): HttpError; | ||
appErrorToErrorObject<T>(err: AppError<T>): ErrorObject<T>; | ||
appErrorToHttpError(err: AppError<HttpErrorData>): HttpError; | ||
} | ||
export declare const errorSharedUtil: ErrorSharedUtil; | ||
export {}; |
@@ -45,2 +45,12 @@ "use strict"; | ||
} | ||
errorObjectToHttpError(o) { | ||
const err = Object.assign(new __1.HttpError(o.message, o.data), { | ||
// name: err.name, // cannot be assigned to a readonly property like this | ||
stack: o.stack, | ||
}); | ||
Object.defineProperty(err, 'name', { | ||
value: o.name, | ||
}); | ||
return err; | ||
} | ||
appErrorToErrorObject(err) { | ||
@@ -54,4 +64,7 @@ return { | ||
} | ||
appErrorToHttpError(err) { | ||
return new __1.HttpError(err.message, err.data); | ||
} | ||
} | ||
exports.errorSharedUtil = new ErrorSharedUtil(); | ||
//# sourceMappingURL=error.shared.util.js.map |
import { memo } from './decorators/memo.decorator'; | ||
import { memoCache } from './decorators/memoCache.decorator'; | ||
import { AppError } from './error/app.error'; | ||
import { ErrorData, ErrorObject, ErrorResponse, HttpErrorData } from './error/error.model'; | ||
import { ErrorData, ErrorObject, ErrorResponse, HttpErrorData, HttpErrorResponse } from './error/error.model'; | ||
import { errorSharedUtil } from './error/error.shared.util'; | ||
@@ -14,2 +14,2 @@ import { HttpError } from './error/http.error'; | ||
import { stringSharedUtil } from './util/string.shared.util'; | ||
export { memo, memoCache, ErrorData, ErrorObject, HttpErrorData, ErrorResponse, AppError, HttpError, deepFreeze, silentConsole, errorSharedUtil, objectUtil, randomSharedUtil, scriptSharedUtil, stringSharedUtil, StringMap, PromiseMap, ClassType, LOG_LEVEL, BasicLogFunction, LogFunction, }; | ||
export { memo, memoCache, ErrorData, ErrorObject, HttpErrorData, ErrorResponse, HttpErrorResponse, AppError, HttpError, deepFreeze, silentConsole, errorSharedUtil, objectUtil, randomSharedUtil, scriptSharedUtil, stringSharedUtil, StringMap, PromiseMap, ClassType, LOG_LEVEL, BasicLogFunction, LogFunction, }; |
{ | ||
"name": "@naturalcycles/js-lib", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "build": "del ./dist && tsc", |
@@ -72,1 +72,3 @@ import { StringMap } from '../types' | ||
} | ||
export type HttpErrorResponse = ErrorResponse<HttpErrorData> |
@@ -1,2 +0,2 @@ | ||
import { AppError, objectUtil } from '..' | ||
import { AppError, HttpError, HttpErrorData, objectUtil } from '..' | ||
import { ErrorObject } from '../error/error.model' | ||
@@ -53,2 +53,15 @@ | ||
errorObjectToHttpError (o: ErrorObject): HttpError { | ||
const err = Object.assign(new HttpError(o.message, o.data), { | ||
// name: err.name, // cannot be assigned to a readonly property like this | ||
stack: o.stack, | ||
}) | ||
Object.defineProperty(err, 'name', { | ||
value: o.name, | ||
}) | ||
return err | ||
} | ||
appErrorToErrorObject<T> (err: AppError<T>): ErrorObject<T> { | ||
@@ -62,4 +75,8 @@ return { | ||
} | ||
appErrorToHttpError (err: AppError<HttpErrorData>): HttpError { | ||
return new HttpError(err.message, err.data) | ||
} | ||
} | ||
export const errorSharedUtil = new ErrorSharedUtil() |
import { memo } from './decorators/memo.decorator' | ||
import { memoCache } from './decorators/memoCache.decorator' | ||
import { AppError } from './error/app.error' | ||
import { ErrorData, ErrorObject, ErrorResponse, HttpErrorData } from './error/error.model' | ||
import { | ||
ErrorData, | ||
ErrorObject, | ||
ErrorResponse, | ||
HttpErrorData, | ||
HttpErrorResponse, | ||
} from './error/error.model' | ||
import { errorSharedUtil } from './error/error.shared.util' | ||
@@ -22,2 +28,3 @@ import { HttpError } from './error/http.error' | ||
ErrorResponse, | ||
HttpErrorResponse, | ||
AppError, | ||
@@ -24,0 +31,0 @@ HttpError, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
104727
1856