diff --git a/src/app/pages/error/error.component.html b/src/app/pages/error/error.component.html
index 0220533..ece95da 100644
--- a/src/app/pages/error/error.component.html
+++ b/src/app/pages/error/error.component.html
@@ -14,7 +14,7 @@
-
+ {{ error }}
Return
diff --git a/src/app/pages/error/error.component.ts b/src/app/pages/error/error.component.ts
index d879c71..3076de6 100644
--- a/src/app/pages/error/error.component.ts
+++ b/src/app/pages/error/error.component.ts
@@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
+import { UDSApiService } from '../../uds-api.service';
declare const django: any;
declare const udsData: any;
@@ -10,9 +11,9 @@ declare const udsData: any;
styleUrls: ['./error.component.css'],
})
export class ErrorComponent implements OnInit {
- error: string[] = [''];
+ error: string;
- constructor(private route: ActivatedRoute) {}
+ constructor(public api: UDSApiService, private route: ActivatedRoute) {}
ngOnInit() {
this.getError();
@@ -20,20 +21,11 @@ export class ErrorComponent implements OnInit {
getError(): void {
const id = this.route.snapshot.paramMap.get('id');
- try {
- const errText = new TextDecoder()
- .decode(
- Uint8Array.from(window.atob(id), (c) => (c as any).charCodeAt(c))
- )
- .replace('<', '<')
- .replace('>', '>');
- // Split error text in lines
- this.error = errText.split('\n');
- console.log(this.error);
- udsData.error = this.error;
- } catch (e) {
- console.log(e);
- this.error = [django.gettext('Invalid error string')];
- }
+ this.error = '';
+ // Request error string from UDS
+ this.api.getErrorInformation(id).subscribe((errInfo) => {
+ // Set error to errInfo.error + Hex code
+ this.error = errInfo.error;
+ });
}
}
diff --git a/src/app/types/config.ts b/src/app/types/config.ts
index 4e37f34..368a72c 100644
--- a/src/app/types/config.ts
+++ b/src/app/types/config.ts
@@ -29,6 +29,7 @@ export interface UDSUrls {
readonly galleryImage: string;
readonly transportIcon: string;
readonly clientDownload: string;
+ readonly error: string;
readonly launch: string;
}
diff --git a/src/app/types/services.ts b/src/app/types/services.ts
index 12a3e8d..02c7d04 100644
--- a/src/app/types/services.ts
+++ b/src/app/types/services.ts
@@ -45,6 +45,11 @@ export interface JSONServicesInformation {
transports: string;
}
+export interface JSONErrorInformation {
+ error: string;
+ code: string;
+}
+
export interface JSONEnabledService {
url: string;
error: string;
diff --git a/src/app/uds-api.service.ts b/src/app/uds-api.service.ts
index eab831a..9c8ba0f 100644
--- a/src/app/uds-api.service.ts
+++ b/src/app/uds-api.service.ts
@@ -9,6 +9,7 @@ import {
JSONStatusService,
JSONService,
JSONTransportURLService,
+ JSONErrorInformation,
} from './types/services';
import { UDSGuiService } from './gui/uds-gui.service';
import { Plugin } from './helpers/plugin';
@@ -141,6 +142,13 @@ export class UDSApiService implements UDSApiServiceType {
return this.http.get(this.config.urls.services);
}
+ /**
+ * Gets error string from a code
+ */
+ getErrorInformation(errorCode: string): Observable {
+ return this.http.get(this.config.urls.error.replace('9999', errorCode));
+ }
+
/**
* Executes custom javascript for service launch if it is available
*/