Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/note-settings-invitation-ha…
Browse files Browse the repository at this point in the history
…sh' into feat/note-settings-invitation-hash
  • Loading branch information
elizachi committed Feb 23, 2024
2 parents 7a22d96 + a61f741 commit cf50bc0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/domain/entities/errors/Forbidden.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import DomainError from './Base';

/**
* Domain error thrown when access denied
*/
export default class ForbiddenError extends DomainError {
/**
* Constructor for Forbidden error
*
* @param message - Error message
*/
constructor(message: string = 'Forbidden') {
super(message);
this.name = 'ForbiddenError';
}
}
4 changes: 3 additions & 1 deletion src/infrastructure/transport/notes-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import AuthorizableTransport from '@/infrastructure/transport/authorizable.trans
import type JSONValue from '../types/JSONValue';
import UnauthorizedError from '@/domain/entities/errors/Unauthorized';
import NotFoundError from '@/domain/entities/errors/NotFound';
import ForbiddenError from '@/domain/entities/errors/Forbidden';

/**
* Additional params that could be specified for request to NoteX API
Expand Down Expand Up @@ -49,8 +50,9 @@ export default class NotesApiTransport extends AuthorizableTransport {
*/
switch (status) {
case 401:
case 403:
return new UnauthorizedError(errorText);
case 403:
return new ForbiddenError(errorText);
case 404:
return new NotFoundError(errorText);
default:
Expand Down

0 comments on commit cf50bc0

Please sign in to comment.