Get a Free Trial

Error Handling with Node.js

DownloadTechnical Information
Node.js API

Every oncomplete callback function in the GrabzIt Node.js API has as its first parameter, a standard Node.js error object. However in order to enable developers to programmatically handle errors this error object, in addition to having a message property also has a code property that contains a error code that directly maps to a error. How each error code maps to an error is indicated in the below table, this avoids the need to parse error messages.

An example of how to use an error object to determine how to handle an error is shown below.

var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");
client.url_to_image("https://www.tesla.com");
client.save_to('images/result.jpg', function(error, result){
    if (error.code == client.ERROR_CODES.PARAMETER_NO_URL)
    {
        //Please enter a URL
    }
});

Error Code Lookup

Error Value Description Code
PARAMETER_NO_URL URL is missing 100
PARAMETER_INVALID_URL Specified URL is invalid 101
PARAMETER_NON_EXISTANT_URL Specified URL does not exist 102
PARAMETER_MISSING_APPLICATION_KEY Application key is missing 103
PARAMETER_UNRECOGNISED_APPLICATION_KEY Application key is not recognised 104
PARAMETER_MISSING_SIGNATURE Signature is missing 105
PARAMETER_INVALID_SIGNATURE Signature is invalid 106
PARAMETER_INVALID_FORMAT Specified format is invalid 107
PARAMETER_INVALID_COUNTRY_CODE Specified country code is invalid 108
PARAMETER_DUPLICATE_IDENTIFIER Specified identifier already exists 109
PARAMETER_MATCHING_RECORD_NOT_FOUND Matching record not found 110
PARAMETER_INVALID_CALLBACK_URL Specified callback URL is invalid 111
PARAMETER_NON_EXISTANT_CALLBACK_URL Callback URL does not exist 112
PARAMETER_IMAGE_WIDTH_TOO_LARGE Specified image width too large 113
PARAMETER_IMAGE_HEIGHT_TOO_LARGE Specified image height too large 114
PARAMETER_BROWSER_WIDTH_TOO_LARGE Specified browser height too large 115
PARAMETER_BROWSER_HEIGHT_TOO_LARGE Specified browser width too large 116
PARAMETER_DELAY_TOO_LARGE Specified delay too large 117
PARAMETER_INVALID_BACKGROUND Invalid background parameter for PDF 118
PARAMETER_INVALID_INCLUDE_LINKS Invalid include links parameter for PDF 119
PARAMETER_INVALID_INCLUDE_OUTLINE Invalid include outline parameter for PDF 120
PARAMETER_INVALID_PAGE_SIZE Invalid PDF page size 121
PARAMETER_INVALID_PAGE_ORIENTATION Invalid page orientation for PDF 122
PARAMETER_VERTICAL_MARGIN_TOO_LARGE Vertical margin for PDF too large 123
PARAMETER_HORIZONTAL_MARGIN_TOO_LARGE Horizontal margin for PDF too large 124
PARAMETER_INVALID_COVER_URL Invalid cover URL for PDF 125
PARAMETER_NON_EXISTANT_COVER_URL Specified cover URL for PDF does not exist 126
PARAMETER_MISSING_COOKIE_NAME Missing cookie name 127
PARAMETER_MISSING_COOKIE_DOMAIN Missing cookie domain 128
PARAMETER_INVALID_COOKIE_NAME Invalid cookie name 129
PARAMETER_INVALID_COOKIE_DOMAIN Invalid cookie domain 130
PARAMETER_INVALID_COOKIE_DELETE Invalid cookie delete value 131
PARAMETER_INVALID_COOKIE_HTTP Invalid cookie HTTP value 132
PARAMETER_INVALID_COOKIE_EXPIRY Invalid cookie expiry 133
PARAMETER_INVALID_CACHE_VALUE Invalid cache value 134
PARAMETER_INVALID_DOWNLOAD_VALUE Invalid download value 135
PARAMETER_INVALID_SUPPRESS_VALUE Invalid suppress value 136
PARAMETER_MISSING_WATERMARK_IDENTIFIER Missing watermark identifier 137
PARAMETER_INVALID_WATERMARK_IDENTIFIER Invalid watermark identifier 138
PARAMETER_INVALID_WATERMARK_XPOS Invalid watermark x position 139
PARAMETER_INVALID_WATERMARK_YPOS Invalid watermark y position 140
PARAMETER_MISSING_WATERMARK_FORMAT Watermark not found 141
PARAMETER_WATERMARK_TOO_LARGE Watermark too large 142
PARAMETER_MISSING_PARAMETERS Missing parameters 143
PARAMETER_QUALITY_TOO_LARGE Quality parameter too large 144
PARAMETER_QUALITY_TOO_SMALL Quality parameter too small 145
PARAMETER_REPEAT_TOO_SMALL Repeat parameter too small 149
PARAMETER_INVALID_REVERSE Reverse parameter invalid 150
PARAMETER_FPS_TOO_LARGE Frames per second parameter too large 151
PARAMETER_FPS_TOO_SMALL Frames per second parameter too small 152
PARAMETER_SPEED_TOO_FAST Speed parameter too fast 153
PARAMETER_SPEED_TOO_SLOW Speed parameter too slow 154
PARAMETER_INVALID_COMBINATION The combination of the duration, FPS, width and height parameters is too large 155
PARAMETER_START_TOO_SMALL Start parameter too small 156
PARAMETER_DURATION_TOO_SMALL Duration parameter too small 157
PARAMETER_NO_HTML No HTML was specified 163
PARAMETER_INVALID_TARGET_VALUE Invalid target specified 165
PARAMETER_INVALID_HIDE_VALUE Invalid element to hide specified 166
PARAMETER_INVALID_INCLUDE_IMAGES Include links parameter for DOCX 167
PARAMETER_INVALID_EXPORT_URL Invalid export URL 168
PARAMETER_INVALID_WAIT_FOR_VALUE Invalid wait for specified 169
PARAMETER_INVALID_TRANSPARENT_VALUE Invalid transparent specified 170
PARAMETER_INVALID_ENCRYPTION_KEY Invalid encryption key specified 171
PARAMETER_INVALID_NO_ADS Invalid advert value specified 172
PARAMETER_INVALID_PROXY Invalid HTTP proxy settings provided 173
PARAMETER_INVALID_NO_NOTIFY Invalid cookie notification value specified 174
PARAMETER_INVALID_HD Invalid high definition value specified 176
PARAMETER_INVALID_MEDIA_TYPE Invalid media type value specified 177
PARAMETER_INVALID_PASSWORD Invalid password value specified 178
PARAMETER_INVALID_MERGE Invalid merge identifier specified 179
PARAMETER_INVALID_CLICK_VALUE Invalid CSS selector to click specified 180
NETWORK_SERVER_OFFLINE Server offline 200
NETWORK_GENERAL_ERROR General network error 201
NETWORK_DDOS_ATTACK Distributed Denial of Service attack 202
RENDERING_ERROR General rendering error 300
RENDERING_MISSING_SCREENSHOT Missing screenshot 301
GENERIC_ERROR General error 400
UPGRADE_REQUIRED Upgrade required 500
FILE_SAVE_ERROR File save error 600
FILE_NON_EXISTANT_PATH File path does not exist 601