mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 17:51:24 +01:00
refactor(es modules): modulize utils
This commit is contained in:
parent
11df349394
commit
12e1c9f334
45 changed files with 620 additions and 283 deletions
8
src/utils/errorUtils.ts
Normal file
8
src/utils/errorUtils.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// parse error to get the readable string
|
||||
export function parseError(error: Error) {
|
||||
const errorString = error.toString() + " " + error.stack;
|
||||
const regex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi;
|
||||
const errorNoURL = errorString.replace(regex, url => "<i>" + url.split("/").at(-1) + "</i>");
|
||||
const errorParsed = errorNoURL.replace(/at /gi, "<br> at ");
|
||||
return errorParsed;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue