mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
chore: sentry and nextjs major bumps (#633)
* chore: remove nextjs-config * build fix * sentry update * nextjs update * feature flags doc * update readme * explicit nextjs env vars + remove feature-unrelated things and obsolete vars from config * full config removal * remove force-dynamic from pages * compile fix * restore claude-deleted tests * no sentry backward compat * better .env.example * AUTHENTIK_REFRESH_TOKEN_URL not so required * accommodate auth system to requiredLogin feature --------- Co-authored-by: Igor Loskutov <igor.loskutoff@gmail.com>
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
function shouldShowError(error: Error | null | undefined) {
|
||||
import { isNonEmptyArray, NonEmptyArray } from "./array";
|
||||
|
||||
export function shouldShowError(error: Error | null | undefined) {
|
||||
if (
|
||||
error?.name == "ResponseError" &&
|
||||
(error["response"].status == 404 || error["response"].status == 403)
|
||||
@@ -8,4 +10,40 @@ function shouldShowError(error: Error | null | undefined) {
|
||||
return true;
|
||||
}
|
||||
|
||||
export { shouldShowError };
|
||||
const defaultMergeErrors = (ex: NonEmptyArray<unknown>): unknown => {
|
||||
try {
|
||||
return new Error(
|
||||
ex
|
||||
.map((e) =>
|
||||
e ? (e.toString ? e.toString() : JSON.stringify(e)) : `${e}`,
|
||||
)
|
||||
.join("\n"),
|
||||
);
|
||||
} catch (e) {
|
||||
console.error("Error merging errors:", e);
|
||||
return ex[0];
|
||||
}
|
||||
};
|
||||
|
||||
type ReturnTypes<T extends readonly (() => any)[]> = {
|
||||
[K in keyof T]: T[K] extends () => infer R ? R : never;
|
||||
};
|
||||
|
||||
// sequence semantic for "throws"
|
||||
// calls functions passed and collects its thrown values
|
||||
export function sequenceThrows<Fns extends readonly (() => any)[]>(
|
||||
...fs: Fns
|
||||
): ReturnTypes<Fns> {
|
||||
const results: unknown[] = [];
|
||||
const errors: unknown[] = [];
|
||||
|
||||
for (const f of fs) {
|
||||
try {
|
||||
results.push(f());
|
||||
} catch (e) {
|
||||
errors.push(e);
|
||||
}
|
||||
}
|
||||
if (errors.length) throw defaultMergeErrors(errors as NonEmptyArray<unknown>);
|
||||
return results as ReturnTypes<Fns>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user