generated from AthennaIO/Template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(errors): throw exception on error of connections
- Loading branch information
Showing
3 changed files
with
60 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* @athenna/database | ||
* | ||
* (c) João Lenon <lenon@athenna.io> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
import { Exception } from '@secjs/utils' | ||
|
||
export class CloseConnectionFailedException extends Exception { | ||
/** | ||
* Creates a new instance of CloseConnectionFailedException. | ||
* | ||
* @return {CloseConnectionFailedException} | ||
*/ | ||
constructor(driverName, error) { | ||
const content = `Error occurred when trying to close the connection with database for ${driverName} driver.` | ||
|
||
super( | ||
content, | ||
500, | ||
'E_CLOSE_CONNECTION_FAILED_ERROR', | ||
`${JSON.stringify(error, null, 2)}`, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* @athenna/database | ||
* | ||
* (c) João Lenon <lenon@athenna.io> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
import { Exception } from '@secjs/utils' | ||
|
||
export class ConnectionFailedException extends Exception { | ||
/** | ||
* Creates a new instance of ConnectionFailedException. | ||
* | ||
* @return {ConnectionFailedException} | ||
*/ | ||
constructor(conName, driverName, error) { | ||
const content = `Error occurred when trying to connect to database using ${conName} connection and ${driverName} driver.` | ||
|
||
super( | ||
content, | ||
500, | ||
'E_CONNECTION_FAILED_ERROR', | ||
`${JSON.stringify(error, null, 2)}`, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters