Кейс: построить callstack вызова функции для поиска, что именно приводит к ошибке. Решение: https://www.heyfirst.co/posts/stacktrace-is-underrated `function getCallSite(): string { const stack = new Error().stack; // this is not an Error, we just want the stack. if (!stack) return "unknown";
// Split the stack into lines and get the 3rd line (index 2)
// Line 0: Error
// Line 1: getCallSite function itself
// Line 2: The actual calling function (what we want!)
const lines = stack.split("n");
const callSiteLine = lines[2]; // The calling function
const match = callSiteLine.match(/ats+(.+?)s+(/); return match ? match[1] : "unknown"; }
// Usage example
function processUser(userId: string) {
console.log(processUser called from: ${getCallSite()});
// ... your logic here
}`