-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from mapeveri/feat/90
feat: improve error handler
- Loading branch information
Showing
19 changed files
with
95 additions
and
41 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
src/languages/domain/country/exceptions/countryAlreadyExistsException.ts
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import DomainException from '@src/shared/domain/exceptions/domainException'; | ||
import ConflictException from '@src/shared/domain/exceptions/conflictException'; | ||
|
||
export default class CountryAlreadyExistsException extends DomainException { | ||
export default class CountryAlreadyExistsException extends ConflictException { | ||
constructor(countryId: string) { | ||
super(`Country with id ${countryId} already exists`, 500, 'country_already_exists'); | ||
super(`Country with id ${countryId} already exists`, 'country_already_exists'); | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
src/languages/domain/expression/exceptions/expressionAlreadyExistsException.ts
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import DomainException from '@src/shared/domain/exceptions/domainException'; | ||
import ConflictException from '@src/shared/domain/exceptions/conflictException'; | ||
|
||
export default class ExpressionAlreadyExistsException extends DomainException { | ||
export default class ExpressionAlreadyExistsException extends ConflictException { | ||
constructor(expressionId: string) { | ||
super(`Expression with id ${expressionId} already exists`, 500, 'expression_already_exists'); | ||
super(`Expression with id ${expressionId} already exists`, 'expression_already_exists'); | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
src/languages/domain/user/exceptions/invalidUserIdException.ts
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import DomainException from '@src/shared/domain/exceptions/domainException'; | ||
import ConflictException from '@src/shared/domain/exceptions/conflictException'; | ||
|
||
export default class InvalidUserIdException extends DomainException { | ||
export default class InvalidUserIdException extends ConflictException { | ||
constructor(userId: string) { | ||
super(`Invalid user id ${userId}`, 400, 'invalid_user_id'); | ||
super(`Invalid user id ${userId}`, 'invalid_user_id'); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import DomainException from '@src/shared/domain/exceptions/domainException'; | ||
import UnauthorizedException from '@src/shared/domain/exceptions/unauthorizedException'; | ||
|
||
export default class LoginException extends DomainException { | ||
export default class LoginException extends UnauthorizedException { | ||
constructor() { | ||
super('Invalid login', 403, 'invalid_login'); | ||
super('Invalid login', 'invalid_login'); | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
src/languages/domain/user/exceptions/userDoesNotExistsException.ts
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import DomainException from '@src/shared/domain/exceptions/domainException'; | ||
import NotFoundException from '@src/shared/domain/exceptions/notFoundException'; | ||
|
||
export default class UserDoesNotExistsException extends DomainException { | ||
export default class UserDoesNotExistsException extends NotFoundException { | ||
constructor(userId: string) { | ||
super(`User ${userId} doesn not exists`, 404, 'user_does_not_exists'); | ||
super(`User ${userId} does not exists`, 'user_does_not_exists'); | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
src/languages/domain/word/exceptions/wordAlreadyExistsException.ts
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import DomainException from '@src/shared/domain/exceptions/domainException'; | ||
import ConflictException from '@src/shared/domain/exceptions/conflictException'; | ||
|
||
export default class WordAlreadyExistsException extends DomainException { | ||
export default class WordAlreadyExistsException extends ConflictException { | ||
constructor(wordId: string) { | ||
super(`Word with id ${wordId} already exists`, 500, 'word_already_exists'); | ||
super(`Word with id ${wordId} already exists`, 'word_already_exists'); | ||
} | ||
} |
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
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
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,7 @@ | ||
import DomainException from '@src/shared/domain/exceptions/domainException'; | ||
|
||
export default class ConflictException extends DomainException { | ||
constructor(public message: string, public code: string) { | ||
super(message, code); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
export default class DomainException extends Error { | ||
constructor(public message: string, public status: number, public code: string) { | ||
constructor(public message: string, public code: string) { | ||
super(message); | ||
this.status = status; | ||
this.code = code; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import DomainException from './domainException'; | ||
import ConflictException from '@src/shared/domain/exceptions/conflictException'; | ||
|
||
export default class InvalidArgumentException extends DomainException { | ||
export default class InvalidArgumentException extends ConflictException { | ||
constructor(public message: string = 'Invalid argument', public code: string = 'invalid_argument') { | ||
super(message, 500, code); | ||
super(message, code); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import DomainException from './domainException'; | ||
import { ConflictException } from '@nestjs/common'; | ||
|
||
export default class InvalidEmailException extends DomainException { | ||
export default class InvalidEmailException extends ConflictException { | ||
constructor(public message: string = 'Invalid email', public code: string = 'invalid_email') { | ||
super(message, 500, code); | ||
super(message, code); | ||
} | ||
} |
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,7 @@ | ||
import DomainException from '@src/shared/domain/exceptions/domainException'; | ||
|
||
export default class NotFoundException extends DomainException { | ||
constructor(public message: string, public code: string) { | ||
super(message, code); | ||
} | ||
} |
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,7 @@ | ||
import DomainException from '@src/shared/domain/exceptions/domainException'; | ||
|
||
export default class UnauthorizedException extends DomainException { | ||
constructor(public message: string = 'User unauthorized', public code: string = 'user_unauthorized') { | ||
super(message, code); | ||
} | ||
} |
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
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
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
4 changes: 2 additions & 2 deletions
4
src/shared/infrastructure/api/serializers/apiExceptionSerializer.ts
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
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