mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-16 16:40:06 +00:00
fix: predefine jsonParseArrayError message
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
export class JsonParseArrayError extends Error {
|
export class JsonParseArrayError extends Error {
|
||||||
constructor(public message: string) {
|
constructor() {
|
||||||
super(message)
|
super('Can not parse array object to json.')
|
||||||
this.name = 'JsonParseArrayError'
|
this.name = 'JsonParseArrayError'
|
||||||
Object.setPrototypeOf(this, JsonParseArrayError.prototype)
|
Object.setPrototypeOf(this, JsonParseArrayError.prototype)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import { JsonParseArrayError, InvalidJsonError } from '../types/errors'
|
|||||||
*/
|
*/
|
||||||
export const getValidJson = (str: string | object) => {
|
export const getValidJson = (str: string | object) => {
|
||||||
try {
|
try {
|
||||||
const arrayErrorMessage = 'Can not parse array object to json.'
|
if (Array.isArray(str)) throw new JsonParseArrayError()
|
||||||
if (Array.isArray(str)) throw new JsonParseArrayError(arrayErrorMessage)
|
|
||||||
|
|
||||||
if (typeof str === 'object') return str
|
if (typeof str === 'object') return str
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user