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:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user