// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { isError } from "@typespec/ts-http-runtime/internal/util";
/**
 * Given what is thought to be an error object, return the message if possible.
 * If the message is missing, returns a stringified version of the input.
 * @param e - Something thrown from a try block
 * @returns The error message or a string of the input
 */
export function getErrorMessage(e) {
    if (isError(e)) {
        return e.message;
    }
    else {
        let stringified;
        try {
            if (typeof e === "object" && e) {
                stringified = JSON.stringify(e);
            }
            else {
                stringified = String(e);
            }
        }
        catch (err) {
            stringified = "[unable to stringify input]";
        }
        return `Unknown error ${stringified}`;
    }
}//# sourceMappingURL=https://main.vscode-cdn.net/sourcemaps/61b3d0ab13be7dda2389f1d3e60a119c7f660cc3/node_modules/@azure/core-util/dist/esm/error.js.map