title: Google apps script not throwing exception
body: <p>I have been playing around google apps script for a while, and I stumbled across the "Your input contains more than the maximum of 50000 characters in a single cell" error. But when I tried to prevent my script from crashing because of it, using try-catch statement, it didn't work.</p>
  
  <p>I checked in the Google apps script documentation site (<a href="https://developers.google.com/apps-script/" rel="nofollow noreferrer">https://developers.google.com/apps-script/</a>), and found nothing.</p>
  
  <p>Moreover, I tried to run that sample code:
  </p>
  
  <pre><code>function myFunction() {
    try
    {
      var a = ""
      for (i =  0; i&lt; 50000; i++)
         a += '111'
         SpreadsheetApp.open(DriveApp.getFileById("FileID")).getActiveSheet().getRange(1,1).setValue(a)
    }
    catch (e)
    {
       Logger.log(e.message)
    }
  }
  </code></pre>
  
  <p>And it crashed, leaving no record in the log.</p>
  
  <p>Any idea on how to prevent crashing? preferably with some code segment that will allow me to manipulate the input?</p>
  
  <p>I will be grateful for any help.</p>
  
  <h2>EDIT</h2>
  
  <p>My script should handle big amounts of data, so running time is really important for me. Right now I'm using a solution that looks like</p>
  
  <pre><code>a.substring (0,50000)
  </code></pre>
  
  <p>But the thing that I really want to see is something that will be activated only when needed, so it will be faster...</p>