UNPKG

@belgattitude/http-exception

Version:

Warning: has been moved to @httpx/exception. Please update.

19 lines (16 loc) 569 B
import { objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js'; import { SerializerError } from '../error/SerializerError.js'; import { convertToSerializable } from '../mapper/convertToSerializable.js'; var toJson = function toJson(exception) { var serializable = convertToSerializable(exception); var v; try { v = JSON.stringify(serializable); } catch (e) { throw new SerializerError("Can't encode into json", _objectSpread2({}, e instanceof Error ? { cause: e } : {})); } return v; }; export { toJson };