feat: Enrich error responses

This commit is contained in:
Faruk AYDIN
2022-11-07 22:51:30 +01:00
parent ad46b3eea3
commit 06a2014bc1
13 changed files with 97 additions and 101 deletions

View File

@@ -2,6 +2,7 @@ import Context from '../../types/express/context';
import axios from 'axios';
import globalVariable from '../../helpers/global-variable';
import App from '../../models/app';
import CreateAuthDataError from '../../errors/create-auth-data';
type Params = {
input: {
@@ -30,12 +31,11 @@ const createAuthData = async (
const app = await App.findOneByKey(connection.key);
const $ = await globalVariable({ connection, app });
await authInstance.createAuthData($);
try {
await authInstance.createAuthData($);
await axios.get(connection.formattedData.url as string);
} catch (error) {
throw new Error('Error occured while creating authorization URL!');
throw new CreateAuthDataError(error);
}
return connection.formattedData;