-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new errors classes relantionship
- Loading branch information
Showing
5 changed files
with
59 additions
and
12 deletions.
There are no files selected for viewing
12 changes: 9 additions & 3 deletions
12
public/react-services/error-handler/errors/ElasticApiError.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,8 +1,14 @@ | ||
export class ElasticApiError extends Error { | ||
constructor(message: string) { | ||
super(message); | ||
import { WazuhError } from './WazuhError'; | ||
|
||
export class ElasticApiError extends WazuhError { | ||
constructor(error: Error, message: string, code: number) { | ||
super(error,message, code); | ||
// Because we are extending built in class | ||
Object.setPrototypeOf(this, ElasticApiError.prototype); | ||
this.name = this.constructor.name; | ||
} | ||
|
||
handleError(){ | ||
console.log('Show error'); | ||
} | ||
} |
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,8 +1,14 @@ | ||
export class ElasticError extends Error { | ||
constructor(message: string) { | ||
super(message); | ||
import { WazuhError } from "./WazuhError"; | ||
|
||
export class ElasticError extends WazuhError { | ||
constructor(error: Error, message: string, code: number) { | ||
super(error,message, code); | ||
// Because we are extending built in class | ||
Object.setPrototypeOf(this, ElasticError.prototype); | ||
this.name = this.constructor.name; | ||
} | ||
|
||
handleError(){ | ||
console.log('Show error'); | ||
} | ||
} |
12 changes: 9 additions & 3 deletions
12
public/react-services/error-handler/errors/WazuhApiError.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,8 +1,14 @@ | ||
export class WazuhApiError extends Error { | ||
constructor(message: string) { | ||
super(message); | ||
import { WazuhError } from "./WazuhError"; | ||
|
||
export class WazuhApiError extends WazuhError { | ||
constructor(error: Error, message: string, code: number) { | ||
super(error,message, code); | ||
// Because we are extending built in class | ||
Object.setPrototypeOf(this, WazuhApiError.prototype); | ||
this.name = this.constructor.name; | ||
} | ||
|
||
handleError(){ | ||
console.log('Show error'); | ||
} | ||
} |
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,23 @@ | ||
interface iWazuhError { | ||
error: Error; | ||
message: string; | ||
code: number; | ||
handleError(): void; | ||
} | ||
|
||
export abstract class WazuhError extends Error implements iWazuhError { | ||
error: Error; | ||
message: string; | ||
code: number; | ||
constructor(error: Error, message: string, code: number) { | ||
super(message); | ||
this.error = error; | ||
this.message = message; | ||
this.code = code; | ||
} | ||
|
||
/** | ||
* This method decides how to treat the error | ||
*/ | ||
abstract handleError(): void; | ||
} |
12 changes: 9 additions & 3 deletions
12
public/react-services/error-handler/errors/WazuhReportingError.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,8 +1,14 @@ | ||
export class WazuhReportingError extends Error { | ||
constructor(message: string) { | ||
super(message); | ||
import { WazuhError } from "./WazuhError"; | ||
|
||
export class WazuhReportingError extends WazuhError { | ||
constructor(error: Error, message: string, code: number) { | ||
super(error,message, code); | ||
// Because we are extending built in class | ||
Object.setPrototypeOf(this, WazuhReportingError.prototype); | ||
this.name = this.constructor.name; | ||
} | ||
|
||
handleError(){ | ||
console.log('Show error'); | ||
} | ||
} |