Skip to content

Commit 64e950c

Browse files
committed
include realm URL in error response
1 parent 7173fa1 commit 64e950c

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

Diff for: packages/host/app/resources/card-resource.ts

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export interface CardError {
3535
status: number;
3636
title: string;
3737
message: string;
38+
realm: string;
3839
meta: {
3940
lastKnownGoodHtml: string | null;
4041
scopedCssUrls: string[];
@@ -283,6 +284,7 @@ export class CardResource extends Resource<Args> {
283284
status: 404,
284285
title: 'Card Not Found',
285286
message: `The card ${url.href} does not exist`,
287+
realm: error.responseHeaders.get('X-Boxel-Realm-Url'),
286288
meta: {
287289
lastKnownGoodHtml: null,
288290
scopedCssUrls: [],
@@ -302,6 +304,7 @@ export class CardResource extends Resource<Args> {
302304
message: `Received HTTP ${error.status} from server ${
303305
error.responseText ?? ''
304306
}`.trim(),
307+
realm: error.responseHeaders.get('X-Boxel-Realm-Url'),
305308
meta: {
306309
lastKnownGoodHtml: null,
307310
scopedCssUrls: [],

Diff for: packages/host/app/resources/stack-backgrounds.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Resource } from 'ember-resources';
55

66
import type { Stack } from '../components/operator-mode/interact-submode';
77
import type CardService from '../services/card-service';
8+
import type RealmService from '../services/realm';
89

910
interface Args {
1011
positional: [stacks: Stack[]];
@@ -13,6 +14,7 @@ interface Args {
1314
export class StackBackgroundsResource extends Resource<Args> {
1415
@tracked value: (string | undefined | null)[] = [];
1516
@service declare cardService: CardService;
17+
@service declare realm: RealmService;
1618

1719
get backgroundImageURLs() {
1820
return this.value?.map((u) => (u ? u : undefined)) ?? [];
@@ -47,7 +49,9 @@ export class StackBackgroundsResource extends Resource<Args> {
4749
let bottomMostStackItem = stack[0];
4850
await bottomMostStackItem.ready;
4951
if (bottomMostStackItem.cardError) {
50-
return undefined;
52+
await this.realm.ensureRealmMeta(bottomMostStackItem.cardError.realm);
53+
return this.realm.info(bottomMostStackItem.cardError.realm)
54+
?.backgroundURL;
5155
}
5256
return (await this.cardService.getRealmInfo(bottomMostStackItem.card))
5357
?.backgroundURL;

Diff for: packages/runtime-common/realm.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1405,6 +1405,9 @@ export class Realm {
14051405
status: maybeError.error.errorDetail.status,
14061406
title: maybeError.error.errorDetail.title,
14071407
message: maybeError.error.errorDetail.detail,
1408+
// note that this is actually available as part of the response
1409+
// header too--it's just easier for clients when it is here
1410+
realm: this.url,
14081411
meta: {
14091412
lastKnownGoodHtml: maybeError.error.lastKnownGoodHtml,
14101413
scopedCssUrls: maybeError.error.scopedCssUrls,

0 commit comments

Comments
 (0)