-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throws more useful error when fetch fails (#2921)
- Loading branch information
1 parent
46d7f30
commit 51af025
Showing
9 changed files
with
69 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// loaders.gl | ||
// SPDX-License-Identifier: MIT | ||
// Copyright (c) vis.gl contributors | ||
|
||
export class FetchError extends Error { | ||
constructor(message: string, info: {url: string; reason: string; response?: Response}) { | ||
super(message); | ||
this.reason = info.reason; | ||
this.url = info.url; | ||
this.response = info.response; | ||
} | ||
/** A best effort reason for why the fetch failed */ | ||
reason: string; | ||
/** The URL that failed to load. Empty string if not available. */ | ||
url: string; | ||
/** The Response object, if any. */ | ||
response?: Response; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// loaders.gl | ||
// SPDX-License-Identifier: MIT | ||
// Copyright (c) vis.gl contributors | ||
|
||
import test from 'tape-promise/tape'; | ||
import {shortenUrlForDisplay} from '@loaders.gl/core/lib/utils/url-utils'; | ||
|
||
test('shortenUrlForDisplay', async (t) => { | ||
const longUrl = | ||
'http://www.longsitename.com/path1/path2/path3/longpath/longresourcename.extension'; | ||
const shortUrl = shortenUrlForDisplay(longUrl); | ||
|
||
t.equal(shortUrl, 'http://www.longsitename.com/path...ename.extension'); | ||
t.end(); | ||
}); |