Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/esm/error/index.js>toObject

A JavaScript extension package for building strong and modern applications.
Latest
function toObject
import { toObject } from "https://deno.land/x/ayonli_jsext@v0.9.72/esm/error/index.js";

Transforms the error to a plain object.

Examples

Example 1

import { toObject } from "@ayonli/jsext/error";

const err = new Error("Something went wrong.");

const obj = toObject(err);
console.log(obj);
// {
//     "@@type": "Error",
//     name: "Error",
//     message: "Something went wrong.",
//     stack: "Error: Something went wrong.\n    at <anonymous>:1:13"
// }