Created
January 1, 2026 15:56
-
-
Save Mistium/3c587341d32d71d8da696becf4574c52 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Object.defineProperty(Error.prototype, "lineNumber", { | |
| configurable: true, | |
| enumerable: false, | |
| get: function () { | |
| if (!this.stack) return undefined; | |
| const match = this.stack.match(/:(\d+):\d+\)?$/m); | |
| return match ? Number(match[1]) : undefined; | |
| } | |
| }); | |
| try { | |
| throw new Error("lmao") | |
| } catch (e) { | |
| console.log(e.lineNumber) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment