Skip to content

Commit 2cd5dfe

Browse files
committed
feat(index): better error messages
1 parent 0fe350e commit 2cd5dfe

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function getPsiUrl(url, env) {
4848
*/
4949
async function isDomainkeyValid(domain, key) {
5050
if (!domain || !key) {
51-
throw new Error('invalid domain or key');
51+
throw new Error('missing domain or key');
5252
}
5353
try {
5454
const beurl = new URL(`https://rum.fastly-aem.page/domains/${domain}`);
@@ -62,11 +62,11 @@ async function isDomainkeyValid(domain, key) {
6262
},
6363
});
6464
if (!beresp.ok) {
65-
throw new Error('invalid domain or key');
65+
throw new Error('unable to fetch from RUM Bundler API: ' + beresp.statusText);
6666
}
6767
return true;
6868
} catch (e) {
69-
throw new Error('invalid domain or key', e);
69+
throw new Error('other error validating domain key: ' + e.message);
7070
}
7171
}
7272

@@ -92,7 +92,7 @@ async function handleCorsRoute(req, env) {
9292
return new Response('', {
9393
status: 404,
9494
headers: {
95-
'x-error': 'not found',
95+
'x-error': 'not found: ' + beresp.statusText,
9696
},
9797
});
9898
}

0 commit comments

Comments
 (0)