diff --git a/.dist/localuser.js b/.dist/localuser.js index b3e7f5c..b9e7cef 100644 --- a/.dist/localuser.js +++ b/.dist/localuser.js @@ -7,7 +7,7 @@ import { getapiurls, getBulkInfo, setTheme } from "./login.js"; import { SnowFlake } from "./snowflake.js"; import { Message } from "./message.js"; import { Member } from "./member.js"; -import { Settings } from "./settings.js"; +import { FormError, Settings } from "./settings.js"; import { MarkDown } from "./markdown.js"; const wsCodesRetry = new Set([4000, 4003, 4005, 4007, 4008, 4009]); class Localuser { @@ -1045,7 +1045,7 @@ class Localuser { return in1; } else { - throw [copy, "Passwords don't match"]; + throw new FormError(copy, "Passwords don't match"); } }); }); diff --git a/.dist/settings.js b/.dist/settings.js index 823b92e..ed94ffe 100644 --- a/.dist/settings.js +++ b/.dist/settings.js @@ -647,6 +647,16 @@ class Options { } } } +class FormError extends Error { + elem; + message; + constructor(elem, message) { + super(message); + this.message = message; + this.elem = elem; + } +} +export { FormError }; class Form { name; options; @@ -763,11 +773,13 @@ class Form { build[key] = thing(); } catch (e) { - const elm = this.options.html.get(e[0]); - if (elm) { - const html = elm.deref(); - if (html) { - this.makeError(html, e[1]); + if (e instanceof FormError) { + const elm = this.options.html.get(e.elem); + if (elm) { + const html = elm.deref(); + if (html) { + this.makeError(html, e.message); + } } } return; diff --git a/webpage/localuser.ts b/webpage/localuser.ts index 2b38148..c38ce65 100644 --- a/webpage/localuser.ts +++ b/webpage/localuser.ts @@ -9,7 +9,7 @@ import { SnowFlake } from "./snowflake.js"; import { Message } from "./message.js"; import { channeljson, memberjson, presencejson, readyjson } from "./jsontypes.js"; import { Member } from "./member.js"; -import { Settings } from "./settings.js"; +import { FormError, Settings } from "./settings.js"; import { MarkDown } from "./markdown.js"; const wsCodesRetry=new Set([4000,4003,4005,4007,4008,4009]); @@ -1052,7 +1052,7 @@ class Localuser{ if(in1===in2){ return in1; }else{ - throw [copy,"Passwords don't match"] + throw new FormError(copy,"Passwords don't match"); } }) }); diff --git a/webpage/settings.ts b/webpage/settings.ts index f68f0f2..d59f5d7 100644 --- a/webpage/settings.ts +++ b/webpage/settings.ts @@ -649,6 +649,16 @@ class Options implements OptionsElement{ } } } +class FormError extends Error{ + elem:OptionsElement; + message:string; + constructor(elem:OptionsElement,message:string){ + super(message); + this.message=message; + this.elem=elem; + } +} +export {FormError}; class Form implements OptionsElement{ name:string; readonly options:Options; @@ -766,11 +776,13 @@ class Form implements OptionsElement{ try{ build[key]=thing(); }catch(e:any){ - const elm=this.options.html.get(e[0]); - if(elm){ - const html=elm.deref(); - if(html){ - this.makeError(html,e[1]); + if(e instanceof FormError){ + const elm=this.options.html.get(e.elem); + if(elm){ + const html=elm.deref(); + if(html){ + this.makeError(html,e.message); + } } } return;