Using Bugs Radar is very easy for geeks.
Enough send POST request to https://bugsradar.com/api/v1/SendException.ashx and get all data errors on email and dashboard.
Please always send required parameters. For better results send all parameters.
Argument | Required |
ApiKey Your program's key |
|
Message Exception message |
|
Source Source |
|
StackTrace StackTrace |
|
CurrentVersion The version number of the program that is run |
|
Module Module name |
|
ExceptionType ExceptionType |
|
InnerMessage InnerMessage |
|
InnerSource InnerSource |
|
InnerStackTrace InnerStackTrace |
|
CustomMessage Your custom message |
using BugsRadar;
try
{
// Do something that can throw an exception
}
catch (Exception _error)
{
BugsRadar.SendException(_error);
}
Add the following class (BugsRadar.cs) to your project
using System;
public class BugsRadar
{
private static string apikey = "PROJECT API KEY";
public static void SendException(Exception Exception)
{
SendExceptionService(Exception, "", "", "");
}
public static void SendException(Exception Exception,
string CustomMessage)
{
SendExceptionService(Exception, CustomMessage + "", "", "");
}
public static void SendException(Exception Exception,
string CustomMessage,
string Module)
{
SendExceptionService(Exception, CustomMessage + "", Module + "", "");
}
public static void SendException(Exception Exception,
string CustomMessage,
string Module,
string Version)
{
SendExceptionService(Exception, CustomMessage, Module, Version);
}
private static void SendExceptionService(Exception _Exception, string CustomMessage, string Module, string Version)
{
if (_Exception.InnerException != null)
{
POST("https://bugsradar.com/api/v1/SendException.ashx",
"ApiKey=" + apikey +
"&CurrentVersion=" + Version +
"&Module=" + Module +
"&ExceptionType=" + _Exception.GetType().ToString() +
"&Message=" + SanitizeString(_Exception.Message) +
"&Source=" + _Exception.Source +
"&StackTrace=" + SanitizeString(_Exception.StackTrace) +
"&InnerMessage=" + SanitizeString(_Exception.InnerException.Message) +
"&InnerSource=" + _Exception.InnerException.Source +
"&InnerStackTrace=" + SanitizeString(_Exception.InnerException.StackTrace) +
"&CustomMessage=" + SanitizeString(CustomMessage));
}
else
{
POST("https://bugsradar.com/api/v1/SendException.ashx",
"ApiKey=" + apikey +
"&CurrentVersion=" + Version +
"&Module=" + Module +
"&ExceptionType=" + _Exception.GetType().ToString() +
"&Message=" + SanitizeString(_Exception.Message) +
"&Source=" + _Exception.Source +
"&StackTrace=" + SanitizeString(_Exception.StackTrace) +
"&InnerMessage= &InnerSource= &InnerStackTrace= " +
"&CustomMessage=" + SanitizeString(CustomMessage));
}
}
private static void POST(string Url, string Data)
{
try
{
System.Net.WebRequest req = System.Net.WebRequest.Create(Url);
req.Method = "POST";
req.Timeout = 100000;
req.ContentType = "application/x-www-form-urlencoded";
byte[] sentData = System.Text.Encoding.GetEncoding(65001).GetBytes(Data);
req.ContentLength = sentData.Length;
System.IO.Stream sendStream = req.GetRequestStream();
sendStream.Write(sentData, 0, sentData.Length);
sendStream.Close();
}
catch{ }
}
private static string SanitizeString(string _string)
{
string result = _string;
result = result.Replace("%", "%25");
result = result.Replace("<", "%3C");
result = result.Replace(">", "%3E");
result = result.Replace("#", "%23");
result = result.Replace("{", "%7B");
result = result.Replace("}", "%7D");
result = result.Replace("|", "%7C");
result = result.Replace("\\", "%5C");
result = result.Replace("^", "%5E");
result = result.Replace("~", "%7E");
result = result.Replace("[", "%5B");
result = result.Replace("]", "%5D");
result = result.Replace("`", "%60");
result = result.Replace(";", "%3B");
result = result.Replace("/", "%2F");
result = result.Replace("?", "%3F");
result = result.Replace(":", "%3A");
result = result.Replace("@", "%40");
result = result.Replace("=", "%3D");
result = result.Replace("&", "%26");
result = result.Replace("$", "%24");
return result;
}
}
include_once("BugsRadar.class.php");
try
{
// Do something that can throw an exception
}
catch (Exception $e) {
BugsRadar::SendException($e);
}
Add the following class (BugsRadar.class.php) to your project
class BugsRadar{
private static $apikey = "PROJECT API KEY";
public static function SendException(Exception $Exception,
$CurrentVersion="",
$Module="",
$CustomMessage="")
{
try
{
$ci = curl_init("https://bugsradar.com/api/v1/SendException.ashx");
$data = "ApiKey=".urlencode(self::$apikey).
"&CurrentVersion=".urlencode($CurrentVersion).
"&Module=".urlencode($Module).
"&Message=".urlencode($Exception->getMessage()).
"&Source=".urlencode("File: ".$Exception->getFile().
" Line: ".$Exception->getLine().
" Code: ".$Exception->getCode()
).
"&StackTrace=".urlencode($Exception->getTraceAsString()).
"&InnerMessage=".urlencode("").
"&InnerSource=".urlencode("").
"&InnerStackTrace=".urlencode("").
"&CustomMessage=".urlencode($CustomMessage);
curl_setopt($ci, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ci, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ci, CURLOPT_POST, true);
curl_setopt($ci, CURLOPT_POSTFIELDS, $data);
curl_exec($ci);
}
catch (Exception $e){
exceptionHandlerClass::exceptionLog($e);
}
}
}
actionscript
objectivec
javascript
Need examples in another language? Request a new example