Skip to content

Commit

Permalink
Add status code and response to Similarweb errors (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
hkamran80 authored Sep 3, 2024
1 parent a680564 commit 79700d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"name": "pr-validator",
"version": "0.0.0",
"type": "module",
"private": true,
"scripts": {
"deploy": "wrangler deploy",
"dev": "wrangler dev",
"start": "wrangler dev",
"format": "prettier . --write"
},
"dependencies": {
"crypto-js": "^4.2.0",
"oauth-1.0a": "^2.2.6"
},
"devDependencies": {
"itty-router": "^3.0.12",
"prettier": "^3.3.2",
"wrangler": "^3.0.0"
},
"type": "module",
"dependencies": {
"crypto-js": "^4.2.0",
"oauth-1.0a": "^2.2.6"
}
}
7 changes: 4 additions & 3 deletions src/tests/SimilarWeb.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logger from '../logger.js';

const test = 'SimilarWeb';
const test = 'Similarweb';

/**
* Retrieve the Similarweb rank for a given domain
Expand All @@ -26,8 +26,9 @@ export default async function (entryDomain, env, file) {
}

if (!res.ok) {
if (!file) throw new Error('Unable to fetch website rank');
else logger.addWarning(file, `Unable to fetch website rank for additional domain ${domain}`);
const errorDetails = `HTTP error ${res.status}\nError message: ${await res.text()}`;
if (!file) throw new Error(`Unable to fetch website rank — ${errorDetails}`);
else logger.addWarning(file, `Unable to fetch website rank for additional domain ${domain}${errorDetails}`);
}

const json = await res.json();
Expand Down

0 comments on commit 79700d4

Please sign in to comment.