@luizleon/sf.prefeiturasp.vuecomponents 0.0.23 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/common/appResult.ts +12 -0
package/package.json
CHANGED
package/src/common/appResult.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export class AppResult<Value = null> {
|
|
2
2
|
constructor(value: Value | null = null) {
|
|
3
3
|
this._value = value;
|
|
4
|
+
this._httpStatusCode = 200;
|
|
4
5
|
}
|
|
5
6
|
errors: string[] = [];
|
|
6
7
|
private _value?: Value | null = null;
|
|
8
|
+
private _httpStatusCode: number;
|
|
7
9
|
get value() {
|
|
8
10
|
return this._value as Value;
|
|
9
11
|
}
|
|
@@ -16,7 +18,17 @@ export class AppResult<Value = null> {
|
|
|
16
18
|
get hasError(): boolean {
|
|
17
19
|
return this.errors.length > 0;
|
|
18
20
|
}
|
|
21
|
+
get httpStatusCode() {
|
|
22
|
+
return this._httpStatusCode;
|
|
23
|
+
}
|
|
24
|
+
set httpStatusCode(v: number) {
|
|
25
|
+
this._httpStatusCode = v;
|
|
26
|
+
}
|
|
19
27
|
WithError(error: string) {
|
|
20
28
|
this.errors.push(error);
|
|
29
|
+
if (this._httpStatusCode === 200) this._httpStatusCode = 400;
|
|
30
|
+
}
|
|
31
|
+
WithErrors(errors: string[]) {
|
|
32
|
+
errors.forEach((error) => this.WithError(error));
|
|
21
33
|
}
|
|
22
34
|
}
|