tangled
alpha
login
or
join now
cosmik.network
/
semble
43
fork
atom
A social knowledge tool for researchers built on ATProto
43
fork
atom
overview
issues
13
pulls
pipelines
update app error and use case error
Wesley Finck
5 months ago
f4686b62
a6f57ec1
+8
-4
2 changed files
expand all
collapse all
unified
split
src
shared
core
AppError.ts
UseCaseError.ts
+3
-3
src/shared/core/AppError.ts
···
2
2
import { UseCaseError } from './UseCaseError';
3
3
4
4
export namespace AppError {
5
5
-
export class UnexpectedError extends Err<any, UseCaseError> {
5
5
+
export class UnexpectedError extends UseCaseError {
6
6
message: string;
7
7
public constructor(err: any) {
8
8
-
super(Error(`An unexpected error occurred.`));
8
8
+
super(`An unexpected error occurred.`);
9
9
console.log(`[AppError]: An unexpected error occurred`);
10
10
console.error(err);
11
11
-
this.message = JSON.stringify(err);
11
11
+
this.message = err.toString ? err.toString() : JSON.stringify(err);
12
12
}
13
13
14
14
public static create(err: any): UnexpectedError {
+5
-1
src/shared/core/UseCaseError.ts
···
1
1
-
interface IUseCaseError {
1
1
+
interface IUseCaseError extends Error {
2
2
message: string;
3
3
}
4
4
5
5
export abstract class UseCaseError implements IUseCaseError {
6
6
public readonly message: string;
7
7
+
public name: string = 'UseCaseError';
7
8
8
9
constructor(message: string) {
9
10
this.message = message;
11
11
+
}
12
12
+
toString(): string {
13
13
+
return `${this.constructor.name}: ${this.message}`;
10
14
}
11
15
}