ErrorStack API

How so I submit errors to ErrorStack?

It's easy. Use our RESTful submit api to submit your errors to ErrorStack through an HTTP GET or POST request. We even have a Javascript example to get you started. Please send us your submission code for other languages and systems you use, and we'll post it here. Who know's you might become famous. :-)

 


Submit Your Sample Code

If you end up creating something cool or a better example than what we have here, let us know. We would love to see how you've made ErrorStack work for you. Your code could end up on this page as a shining example of your genius! (Ok, it's not like we're giving out Nobel prizes or anything, but we'll be sure to give you some props and maybe some cool ErrorStack swag.)

 


Submit (HTTP GET/POST Request)

Submits error information to a specified stack and returns a 1 pixel transparent .gif image.

URL: http://www.errorstack.com/submit?
Method(s): GET,POST
Parameters:

Returns:
Example GET Call: (Formated on multiple lines for easy reading.)
	http://www.errorstack.com/submit?_s=b9db6be7dce0ae1e9cb96a71a7ea8e91&_r=img
	&Msg=Error%20loading%20script
	&URL=http://www.errorstack.com/home
	&Line=15
	&Platform=Win32
	&UserAgent=Mozilla/4.0%20(compatible;%20MSIE%206.0;%20Windows%20NT%205.1;%20SV1;%20.NET%20CLR%202.0.50727)

 

Example POST HTML Form:
	<form action="http://www.errorstack.com/submit" method="post">
	<input type="text" id="_s" name="_s" value="YOUR_STACK_KEY_GOES_HERE"/>
	<input type="text" id="_r" name="_r" value="json"/>
	<input type="text" id="Msg" name="Msg" value="Error loading script"/>
	<input type="text" id="URL" name="URL" value="http://www.errorstack.com/home"/>
	<input type="text" id="Line" name="Line" value="15"/>
	<input type="text" id="Platform" name="Platform" value="Win32"/>
	<input type="text" id="UserAgent" name="UserAgent" value="Mozilla/4.0%20(compatible; ...)"/>
	<input type="submit" value="Submit Error"/>
	</form>

 


GET Example: Javascript AJAX Error Submission Code

This is an example of using the onerror function in javascript to submit javascript errors from any modern bowser. You can use this example as the basis for your submission code. The only required field is "s" (your stack key). Feel free to submit additional error detail you may need.

	onerror = function(msg,url,l){
		var txt="_s=YOUR_STACK_KEY_GOES_HERE&_r=img";
		txt+="&Msg="+escape(msg);
		txt+="&URL="+escape(url);
		txt+="&Line="+l;
		txt+="&Platform="+escape(navigator.platform);
		txt+="&UserAgent="+escape(navigator.userAgent);
		var i = document.createElement("img");
		i.setAttribute("src", (("https:" == document.location.protocol) ? 
			"https://errorstack.appspot.com" : "http://www.errorstack.com") + "/submit?" + txt);
		document.body.appendChild(i);
	}

 

Log (HTTP GET/POST Request)

Need to track simple log messages while you're debuging some code? You can now submit them to this stack as a log message. Only the last 10 log messages are kept for a maximum of 1 hour. No clearing of old messages. Just log them to your stack and use them when you need them.

Logging messages works in the same way as submitting errors above.

URL: http://www.errorstack.com/log?
Method(s): GET,POST
Parameters:

Returns:

HTTPS (SSL) Support

If your webpage uses SSL to secure it's communication, you may have already noticed a pesky browser security message when you submit error messages to ErrorStack. The problem is with the browser warning the user that it's about to display non-SSL content. To fix this error you can submit error messages to our SSL endpoint. Just change the URL from "http://www.errorstack.com/submit?" to "https://errorstack.appspot.com/submit?".

 


Example Python Error Code

You can use the following python code to collect errors occurring in your python projects. For more information on submitting errors please visit our API page.

	import logging

	# Create a logger for your application and set level to ERROR
	logger = logging.getLogger("My_Python_App")
	logger.setLevel(logging.ERROR)

	# Define ErrorStack Handler
	import logging.handlers
	class ErrorStackHandler(logging.handlers.HTTPHandler):
	    def mapLogRecord(self, record):
	        """ Define the values submitted to ErrorStack.com. """
	        keys = ['name','msg','levelname','module','pathname','funcName','lineno',
	                'args','exc_text','threadName','thread','process','asctime']
	        ErrorInfo = {}
	        for key in keys:
	            ErrorInfo[key] = record.__dict__[key]
	        return ErrorInfo
        

	# Create ErrorStack handler, set level to error, and add it to the logger
	ESHandler = ErrorStackHandler("www.errorstack.com", "/submit?_s=YOUR_STACK_KEY_GOES_HERE&_r=json", "POST")
	ESHandler.setLevel(logging.ERROR)
	logger.addHandler(ESHandler)


	# Here are some examples of logging errors in your application code
	logger.error("I'm sorry Dave, I'm afraid I can't do that.", exc_info=True)
	
	try:
	    x=1/0
	except:
	    logger.critical("Houston, we have a problem.", exc_info=True)

 


Wordpress Plugin Information

You can use the ErrorStack Wordpress Plugin to collect errors occurring in your blog.
Steps to Install the Wordpress Plugin:

  1. Just download the plugin from: http://www.errorstack.com/wordpress_plugin_errorstack_1_2.zip
  2. Upzip the file.
  3. Upload the ErrorStack.php file to your plugin directory (in /wp-content/plugins) on your webserver.
  4. Login to your Wordpress admin console, and go to the plugins page to activate the ErrorStack plugin.
  5. Goto the options page and find the ErrorStack options page.
  6. Enter the stackKey in the input box and hit Update.

 


ASP.NET Sample Code

For those websites using ASP.NET, we have a sample Global.asax that will allow you to submit errors to ErrorStack.com. It's written in C# and uses the Application Error event to catch and submit errors. The sample code submits the error message, source, stack trace, and method from context.Server.GetLastError(). Download the sample code from: http://www.errorstack.com/ErrorStack-ASPDotNet.zip

 


Custom Stack Information

You can use the ErrorStack API to collect errors occurring in any system with Internet access and the ability to make an http connection. We suggest using the API documentation on this page, combined with the other examples as a basis for your custom error submission code.

 


Kynetx/Javascript

You can use ErrorStack to report on Javascript errors that occur in the customer's browser running your Kynetx applications. You can define your stack key in the meta block of your application to automatically submit errors, use the built in KOBJ.errorstack_submit function for targeted error reporting, or submit custom errors by emitting the javascript submission code directly.

	<script type="text/javascript">
	onerror = function(msg,url,l){
		var txt="_s=&_r=img";
		txt+="&Msg="+escape(msg);
		txt+="&URL="+escape(url);
		txt+="&Line="+l;
		txt+="&Platform="+escape(navigator.platform);
		txt+="&UserAgent="+escape(navigator.userAgent);
		var i = document.createElement("img");
		i.setAttribute("src", (("https:" == document.location.protocol) ? 
			"https://errorstack.appspot.com" : "http://www.errorstack.com") + "/submit?" + txt);
		document.body.appendChild(i);
	}
	</script>
For more information, please visit http://code.kynetx.com.

 


.Net/C# Sample Code

Harley Pebley has written a .Net wrapper around the ErrorStack API for submitting errors. Include his code in your source and call the log function to submit your errors. You can check out this open source library at: http://code.google.com/p/errorstacklibrary/

 


iPhone Sample Code

Thanks to Evrhet Milam you can use the ErrorStack API to collect errors from the iPhone applications that you develop. The sample code contains a class to send the errors to ErrorStack. Just make a call to this class with your error name and reason (from NSExceptions.) The version of the iPhone platform and the version of your software are automatically included. To get started download the sample code from: http://www.errorstack.com/iPhoneErrorStack.zip

 


CodeIgniter Sample Code

Dan Olsen has written a library for the popular php framework CodeIgniter to track server side php errors. You can download the sample code from: http://code.google.com/p/codeigniter-errorstack/ or review the Installation or Usage Instructions.

 


Django Sample Code

Carl Meyer over at OddBird has put together a great Django integration that reports server side Django errors back to ErrorStack. You can easily install it from PyPI with easy_install or pip.

For more information visit the project repostitories at: