1
0
mirror of https://github.com/sasjs/adapter.git synced 2025-12-11 01:14:36 +00:00

fix: predefine jsonParseArrayError message

This commit is contained in:
2021-08-18 16:09:51 +05:00
parent 78149e6c54
commit e72195ca5d
2 changed files with 3 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
export class JsonParseArrayError extends Error {
constructor(public message: string) {
super(message)
constructor() {
super('Can not parse array object to json.')
this.name = 'JsonParseArrayError'
Object.setPrototypeOf(this, JsonParseArrayError.prototype)
}

View File

@@ -6,8 +6,7 @@ import { JsonParseArrayError, InvalidJsonError } from '../types/errors'
*/
export const getValidJson = (str: string | object) => {
try {
const arrayErrorMessage = 'Can not parse array object to json.'
if (Array.isArray(str)) throw new JsonParseArrayError(arrayErrorMessage)
if (Array.isArray(str)) throw new JsonParseArrayError()
if (typeof str === 'object') return str