mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-01 04:53:40 +00:00
rename frontend to web
This commit is contained in:
8
web/projects/shared/src/classes/http-error.ts
Normal file
8
web/projects/shared/src/classes/http-error.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { HttpErrorResponse } from '@angular/common/http'
|
||||
|
||||
export class HttpError {
|
||||
constructor(private readonly error: HttpErrorResponse) {}
|
||||
|
||||
readonly code = this.error.status
|
||||
readonly message = this.error.statusText
|
||||
}
|
||||
22
web/projects/shared/src/classes/rpc-error.ts
Normal file
22
web/projects/shared/src/classes/rpc-error.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { RPCErrorDetails } from '../types/rpc.types'
|
||||
|
||||
export class RpcError {
|
||||
constructor(private readonly error: RPCErrorDetails) {}
|
||||
|
||||
readonly code = this.error.code
|
||||
readonly message = this.getMessage()
|
||||
|
||||
private getMessage(): string {
|
||||
let message: string
|
||||
|
||||
if (typeof this.error.data === 'string') {
|
||||
message = `${this.error.message}\n\n${this.error.data}`
|
||||
} else {
|
||||
message = this.error.data?.details
|
||||
? `${this.error.message}\n\n${this.error.data.details}`
|
||||
: this.error.message
|
||||
}
|
||||
|
||||
return `RPC ERROR: ${message}`
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user