Skip to content

Instantly share code, notes, and snippets.

@mmcdaris
Last active August 29, 2015 14:05
Show Gist options
  • Save mmcdaris/f0aee25eb3660f04204f to your computer and use it in GitHub Desktop.
Save mmcdaris/f0aee25eb3660f04204f to your computer and use it in GitHub Desktop.
Simulate some exceptions with json and curl! you need your project id and api key

Setup

  1. save both files locally
  2. make simulate.sh executable
chmod +x simulate.sh

Usage

The first argument is intended to be a json file valid against the json schema for an error

Command
./simulate.sh error.json
Output
Opening: https://airbrake.io/locate/1217607737342772185
<a href="https://getexceptional.airbrake.io/projects/92860/groups/506660255/notices/1217607737342772185">Found</a>.
{
"notifier": {
"name": "Curl Notification",
"version": "curl 7.30.0",
"url": "https://help.airbrake.io/kb/api-2/notifier-api-v3"
},
"errors": [
{
"type": "CoffeeException",
"message": "Lack of Caffeine in french roast",
"backtrace": [
{
"file": "coffee",
"line": 20,
"column": 8,
"function": "espresso_machine"
}
]
},
{
"type": "CurryException",
"message": "spice levels are too high!",
"backtrace": [
{
"file": "muraccis",
"line": 66,
"column": 20,
"function": "consume_food_item"
}
]
}
],
"context": {
"os": "Darwin",
"language": "Culinary",
"environment": "eating",
"version": "2.2.2",
"url:": "",
"rootDirectory": "/food/lunch",
"userId": "555",
"userName": "mogramer",
"userEmail": "[email protected]"
},
"environment": {},
"session": {},
"params": {}
}
#!/bin/bash
# variable setup
PROJECT_ID=...
API_KEY=..
URL=https://airbrake.io/api/v3/projects/$PROJECT_ID/notices?key=$API_KEY
JSON="$1"
# curl the data!
RESP=$(curl -s -H "Content-Type: application/json; charset=UTF-8" -X POST -d @$JSON $URL)
LOCATE=$(echo $RESP | grep -oE "https://.+[0-9]")
echo "Opening: $LOCATE"
sleep 0.5
curl $LOCATE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment