Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.
I've tried to make it as lean and unobtrusive as possible.
errors/AppError.js
docker run -d --name es elasticsearch
docker run -d --name logstash --link es:elasticsearch logstash -v /tmp/logstash.conf:/config-dir/logstash.conf logstash logstash -f /config-dir/logstash.conf
docker run --link es:elasticsearch -d kibana
LOGSTASH_ADDRESS=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' logstash)
package main | |
import ( | |
"encoding/json" | |
"log" | |
"time" | |
"code.google.com/p/goauth2/oauth/jwt" | |
bigquery "github.com/google/google-api-go-client/bigquery/v2" | |
) |
import android.content.Context; | |
import android.os.Debug; | |
import java.io.File; | |
public class OomExceptionHandler implements Thread.UncaughtExceptionHandler { | |
private static final String FILENAME = "out-of-memory.hprof"; | |
public static void install(Context context) { | |
Thread.UncaughtExceptionHandler defaultHandler = Thread.getDefaultUncaughtExceptionHandler(); |
'use strict'; | |
module.exports = function CustomError(message, extra) { | |
Error.captureStackTrace(this, this.constructor); | |
this.name = this.constructor.name; | |
this.message = message; | |
this.extra = extra; | |
}; | |
require('util').inherits(module.exports, Error); |
/** | |
* Creates a 'ghost' bitmap version of the given source drawable (ideally a BitmapDrawable). | |
* In the ghost bitmap, the RGB values take on the values from the 'color' argument, while | |
* the alpha values are derived from the source's grayscaled RGB values. The effect is that | |
* you can see through darker parts of the source bitmap, while lighter parts show up as | |
* the given color. The 'invert' argument inverts the computation of alpha values, and looks | |
* best when the given color is a dark. | |
*/ | |
private Bitmap createGhostIcon(Drawable src, int color, boolean invert) { | |
int width = src.getIntrinsicWidth(); |
/** | |
* Converts a string to a "URL-safe" slug. | |
* Allows for some customization with two optional parameters: | |
* | |
* @param {string} Delimiter used. If not specified, defaults to a dash "-" | |
* @param {array} Adds to the list of non-alphanumeric characters which | |
* will be converted to the delimiter. The default list includes: | |
* ['–', '—', '―', '~', '\\', '/', '|', '+', '\'', '‘', '’', ' '] | |
*/ | |
if (!String.prototype.slugify) { |