PageSourceSearch

https://app.curator.io/error-handling.BfHbsWgK.js

js curator.io collected 2026-10-02 02:19:53 UTC 8,379 bytes, 1 lines download raw bytes

1import{k as _sfc_main$3,bE as fetchClass,bM as showError}from"./app.DO7Rbpz0.js";import{_ as _sfc_main$2}from"./SubnavTests.vue_vue_type_script_setup_true_lang.NB4FV6B1.js";import{j as defineComponent,z as createBlock,q as openBlock,O as withCtx,u as createBaseVNode,I as createVNode,E as unref,P as _sfc_main$1,G as createTextVNode,r as ref,w as computed}from"./SkinSwitcher.D-VoR1Uy.js";import"./Subnav.vue_vue_type_style_index_0_lang.Dr3ibCzz.js";import"./external-link.Bel2_tJj.js";const _hoisted_1={class:"row"},_hoisted_2={class:"col-md-12"},_hoisted_3={class:"row"},_hoisted_4={class:"col-md-6"},_hoisted_5={class:"d-flex flex-wrap gap-2 mb-3"},_hoisted_6={class:"d-flex flex-wrap gap-2 mb-3"},_hoisted_7={class:"d-flex flex-wrap gap-2 mb-3"},_hoisted_8={class:"col-md-6"},_hoisted_9={class:"d-flex flex-wrap gap-2 mb-3"},_hoisted_10={class:"d-flex flex-wrap gap-2 mb-3"},_hoisted_11={class:"d-flex flex-wrap gap-2 mb-3"},_hoisted_12={class:"row mt-4"},_hoisted_13={class:"col-md-12"},_hoisted_14={class:"d-flex flex-wrap gap-2 mb-3"},_hoisted_15={class:"d-flex flex-wrap gap-2 mb-3"},_sfc_main=defineComponent({__name:"error-handling",setup(__props){function throwError(){throw new Error("Test error")}function throwStringError(){throw"String error - this is not recommended but possible"}function undefinedPropertyError(){console.log({}.nonExistentProperty.someMethod())}function nullReferenceError(){console.log(null.property)}function methodNotFoundError(){({}).nonExistentMethod()}function typeError(){42 .toUpperCase()}function referenceError(){console.log(undefinedVariable)}function variableNotDefined(){eval("console.log(notDefinedVariable)")}function syntaxError(){eval("const x = ;")}function rangeError(){new Array(-1)}function evalError(){eval('throw new EvalError("Eval error")')}function promiseRejection(){Promise.reject(new Error("Promise rejected"))}const reactiveData=ref({value:null});function componentError(){reactiveData.value={nested:{property:null}},console.log(reactiveData.value.nested.nonExistent.deepProperty)}function reactiveError(){reactiveData.value=null,reactiveData.value.someProperty="value"}const computedValue=computed(()=>null.property);function computedError(){console.log(computedValue.value)}function networkError(){fetch("https://nonexistent-domain-that-will-fail.com/api/data").then(r=>r.json()).catch(r=>{throw new Error(`Network error: ${r.message}`)})}function apiError(){fetch("/api/nonexistent-endpoint").then(r=>{if(!r.ok)throw new Error(`API Error: ${r.status} ${r.statusText}`);return r.json()}).catch(r=>{throw r})}function fetchError(){const r=window.fetch;window.fetch=()=>Promise.reject(new Error("Fetch failed")),fetch("/api/data").then(e=>e.json()).catch(e=>{throw window.fetch=r,new Error(`Fetch error: ${e.message}`)})}function fetch500(){fetchClass.get("/api/test/error500")}function fetch401(){fetchClass.get("/api/test/error401")}function fetch404(){fetchClass.get("/api/test/error404")}function fetch418(){fetchClass.get("/api/test/error418")}async function fetch422(){try{await fetchClass.post("/api/test/error422",{test:"test"})}catch(r){showError(r instanceof Error?r.message:String(r))}}return(r,e)=>(openBlock(),createBlock(_sfc_main$3,{title:"Error Handling"},{nav:withCtx(()=>[createVNode(_sfc_main$2,{current:"error-handling"})]),default:withCtx(()=>[createBaseVNode("div",_hoisted_1,[createBaseVNode("div",_hoisted_2,[e[31]||(e[31]=createBaseVNode("h1",null,"Error Handling Tests",-1)),e[32]||(e[32]=createBaseVNode("p",{class:"mb-4"},"Click any button below to trigger different types of errors to test error handling:",-1)),createBaseVNode("div",_hoisted_3,[createBaseVNode("div",_hoisted_4,[e[8]||(e[8]=createBaseVNode("h3",null,"Basic Errors",-1)),createBaseVNode("div",_hoisted_5,[createVNode(unref(_sfc_main$1),{variant:"primary",onClick:throwError},{default:withCtx(()=>[...e[0]||(e[0]=[createTextVNode('Throw "Test error"',-1)])]),_:1}),createVNode(unref(_sfc_main$1),{variant:"danger",onClick:throwStringError},{default:withCtx(()=>[...e[1]||(e[1]=[createTextVNode("Throw String Error",-1)])]),_:1})]),e[9]||(e[9]=createBaseVNode("h3",null,"Type Errors",-1)),createBaseVNode("div",_hoisted_6,[createVNode(unref(_sfc_main$1),{variant:"secondary",onClick:undefinedPropertyError},{default:withCtx(()=>[...e[2]||(e[2]=[createTextVNode("Undefined Property Error",-1)])]),_:1}),createVNode(unref(_sfc_main$1),{variant:"secondary",onClick:nullReferenceError},{default:withCtx(()=>[...e[3]||(e[3]=[createTextVNode("Null Reference Error",-1)])]),_:1}),createVNode(unref(_sfc_main$1),{variant:"secondary",onClick:methodNotFoundError},{default:withCtx(()=>[...e[4]||(e[4]=[createTextVNode("Method Not Found Error",-1)])]),_:1}),createVNode(unref(_sfc_main$1),{variant:"secondary",onClick:typeError},{default:withCtx(()=>[...e[5]||(e[5]=[createTextVNode("Type Error",-1)])]),_:1})]),e[10]||(e[10]=createBaseVNode("h3",null,"Reference Errors",-1)),createBaseVNode("div",_hoisted_7,[createVNode(unref(_sfc_main$1),{variant:"default",onClick:referenceError},{default:withCtx(()=>[...e[6]||(e[6]=[createTextVNode("Reference Error",-1)])]),_:1}),createVNode(unref(_sfc_main$1),{variant:"default",onClick:variableNotDefined},{default:withCtx(()=>[...e[7]||(e[7]=[createTextVNode("Variable Not Defined",-1)])]),_:1})])]),createBaseVNode("div",_hoisted_8,[e[18]||(e[18]=createBaseVNode("h3",null,"Runtime Errors",-1)),createBaseVNode("div",_hoisted_9,[createVNode(unref(_sfc_main$1),{variant:"secondary",onClick:syntaxError},{default:withCtx(()=>[...e[11]||(e[11]=[createTextVNode("Syntax Error",-1)])]),_:1}),createVNode(unref(_sfc_main$1),{variant:"secondary",onClick:rangeError},{default:withCtx(()=>[...e[12]||(e[12]=[createTextVNode("Range Error",-1)])]),_:1}),createVNode(unref(_sfc_main$1),{variant:"secondary",onClick:evalError},{default:withCtx(()=>[...e[13]||(e[13]=[createTextVNode("Eval Error",-1)])]),_:1})]),e[19]||(e[19]=createBaseVNode("h3",null,"Async Errors",-1)),createBaseVNode("div",_hoisted_10,[createVNode(unref(_sfc_main$1),{variant:"primary",onClick:promiseRe
1jection},{default:withCtx(()=>[...e[14]||(e[14]=[createTextVNode("Promise Rejection",-1)])]),_:1})]),e[20]||(e[20]=createBaseVNode("h3",null,"Vue/Component Errors",-1)),createBaseVNode("div",_hoisted_11,[createVNode(unref(_sfc_main$1),{variant:"outline-primary",onClick:componentError},{default:withCtx(()=>[...e[15]||(e[15]=[createTextVNode("Component Error",-1)])]),_:1}),createVNode(unref(_sfc_main$1),{variant:"outline-primary",onClick:reactiveError},{default:withCtx(()=>[...e[16]||(e[16]=[createTextVNode("Reactive Error",-1)])]),_:1}),createVNode(unref(_sfc_main$1),{variant:"outline-primary",onClick:computedError},{default:withCtx(()=>[...e[17]||(e[17]=[createTextVNode("Computed Error",-1)])]),_:1})])])]),createBaseVNode("div",_hoisted_12,[createBaseVNode("div",_hoisted_13,[e[29]||(e[29]=createBaseVNode("h3",null,"Network & API Errors",-1)),createBaseVNode("div",_hoisted_14,[createVNode(unref(_sfc_main$1),{variant:"outline-danger",onClick:networkError},{default:withCtx(()=>[...e[21]||(e[21]=[createTextVNode("Network Error",-1)])]),_:1}),createVNode(unref(_sfc_main$1),{variant:"outline-danger",onClick:apiError},{default:withCtx(()=>[...e[22]||(e[22]=[createTextVNode("API Error",-1)])]),_:1}),createVNode(unref(_sfc_main$1),{variant:"outline-danger",onClick:fetchError},{default:withCtx(()=>[...e[23]||(e[23]=[createTextVNode("Fetch Error",-1)])]),_:1})]),e[30]||(e[30]=createBaseVNode("h3",null,"API Status Codes (Fetch wrapper)",-1)),createBaseVNode("div",_hoisted_15,[createVNode(unref(_sfc_main$1),{variant:"outline-danger",onClick:fetch500},{default:withCtx(()=>[...e[24]||(e[24]=[createTextVNode("500 Error",-1)])]),_:1}),createVNode(unref(_sfc_main$1),{variant:"outline-danger",onClick:fetch401},{default:withCtx(()=>[...e[25]||(e[25]=[createTextVNode("401 Error",-1)])]),_:1}),createVNode(unref(_sfc_main$1),{variant:"outline-danger",onClick:fetch404},{default:withCtx(()=>[...e[26]||(e[26]=[createTextVNode("404 Error",-1)])]),_:1}),createVNode(unref(_sfc_main$1),{variant:"outline-danger",onClick:fetch418},{default:withCtx(()=>[...e[27]||(e[27]=[createTextVNode("418 Error",-1)])]),_:1}),createVNode(unref(_sfc_main$1),{variant:"outline-danger",onClick:fetch422},{default:withCtx(()=>[...e[28]||(e[28]=[createTextVNode("422 Error",-1)])]),_:1})])])])])])]),_:1}))}});export{_sfc_main as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.