📜 ⬆️ ⬇️

Parable of the missing stack

- Hello, my friend ...
- Uncle, will you again tell me a fairy tale?
- Of course! What a clever boy!
- What about?
“M ... today I will tell you about where too independent boys like you are ...”
- Eh! What does it mean to disappear?
- That is what it means ... On, hold the firestone * stretched out, holding an animal burning by the flame by the tail * Just be careful - it is hot!
- Ah ah ah! He kicks!
- Plant a fire beetle on him - instantly calm down.
- Class! It works!
- Ato! Now tell him:
function throwException( ){ (void 0)() } throwException() 

- He swears!
- It is when he hears something incomprehensible that he starts to water you with glassraces. Now say:
function throwError( ){<br> throw new Error( 'error' )<br>}<br>throwError()<br>
- Something blurted and that's it.
- Yeah, here you see him too lazy to get into your stack.
- How then to be? Sometimes it is necessary to say something like that ...
- Give him here ... * whisper in his ear mantra *
var Error= new function ( Original ){<br><br>Version: 1<br>Description: "repairs mozilla's stacktrace in custom errors" <br>License: 'public domain' <br><br>Implementation:<br><br> var Error= ( window.console && Original && ( new Original ).stack )<br>? function ( message ){<br> var e= new Original( message )<br> var custom= function ( msg, file, line ){<br> restore()<br> if ( other && other.apply( this , arguments ) ) return true <br> if (( e.message != msg )||( e.fileName != file )||( e.lineNumber != line )) return <br> var stack= e.stack.split( '\n' )<br> stack= stack.slice( 2, stack.length - 1 )<br> stack[0].replace( /^.*\(.+?\)@(.+):(\d+)$/, function ( str, file, line ){<br> e.fileName= file<br> e.lineNumber= Number( line )<br> })<br> stack[ stack.length - 1 ]= stack[ stack.length - 1 ].replace( /^@.+:\d+$/, function ( str ){<br> return 'source file()' + str<br> })<br> e.stack= stack.join( '\n' )<br> console.error( e )<br> return true <br> }<br> var other= window.onerror<br> var restore= function (){<br> if ( window.onerror === custom ) window.onerror= other<br> }<br> window.onerror= custom<br> setTimeout( restore, 1 )<br> return e<br> }<br>: Original<br><br>Export: return Error<br><br>Usage: throw new Error( 'custom error' )<br><br>}( window.Error )<br>
- What are you whispering to him?
- Never mind. Now repeat what he said earlier.
- Nikerashebe! Here is this treysanul so treysanul! What's the secret?
- Ha! This is a special, street magic! Let's just say: I was able to convince him that the glass frame is very important to us.
“M ... well, okay, but what about the disappearance of the boys?”
“Ah ... yes ... go to Uncle Chrome, my little Stack, he will explain everything ...”

')

Source: https://habr.com/ru/post/87098/


All Articles