DNS API error message

This commit is contained in:
2024-08-11 12:24:42 -04:00
parent 3e989992df
commit cb87f22d98
6 changed files with 100 additions and 108 deletions
+6 -1
View File
@@ -1,6 +1,7 @@
'use strict';
const axios = require('axios');
const {dnsErrors} = require('./common');
class PorkBun{
@@ -28,7 +29,11 @@ class PorkBun{
return res;
}catch(error){
throw new Error(`PorkPun API ${error.response.status}: ${error.response.data.message}`)
if(!error.response) throw error;
if(error.response.data.message.includes('Invalid API key')){
throw dnsErrors.unauthorized(this);
}
throw dnsErrors.other(this, error.response.status, error.response.data.message)
}
}