Skip to content

Instantly share code, notes, and snippets.

View hagevvashi's full-sized avatar

ハゲワシ hagevvashi

  • Kakaku.com, Inc.
View GitHub Profile
@hagevvashi
hagevvashi / YAML_HIGHLIGHT.md
Last active December 2, 2019 13:16
syntax highlight test
foo:
  bar:
    baz:
      - hoge
      - fuga
      - piyo
@hagevvashi
hagevvashi / unhandled-rejection-sample.md
Created April 4, 2020 17:06
unhandled rejectionを示す例
try {
  await axios.post("/some-resources");
} catch(e) {
  // error handling
  throw e; // this causes unhandled rejection
}
@hagevvashi
hagevvashi / casue-unhandledrejection-sample.md
Last active April 4, 2020 17:15
Promise.rejectionを発生させる例
const causeUnhandledRejectionAfter =
  (timeout: number): Promise<void> =>
    new Promise((resolve, reject): number =>
      setTimeout(reject, timeout));

causeUnhandledRejectionAfter(3000);
@hagevvashi
hagevvashi / onunhandledrejection.md
Created April 5, 2020 07:55
browserにおけるunhandledrejectionの処理方法
window.addEventListener("unhandledrejection", (e: PromiseRejectionEvent): void => {
  // an error loginng
  logError(e.reason);
});
@hagevvashi
hagevvashi / unhandledrejection-node.md
Created April 5, 2020 08:13
unhandledrejection handling for Node.js
process.on("unhandledRejection", (error: {} | null | undefined, promise: Promise<any>) => {
  // an error loging
  logError(error);
})
@hagevvashi
hagevvashi / setTiemout-error.md
Created April 5, 2020 08:31
setTimeout error
// notify event on another event loop
const logError = (e: Error):void => {
  setTimeout((): void => {
    throw e;
  });
}

if (!document.getElementById("app")) {
 logError(new Error("app not found"));
@hagevvashi
hagevvashi / promise-reject.md
Created April 5, 2020 08:37
promise.reject error
// notify error as unhandled rejection
const logError = (e: Error):Promise<void> => Promise.reject(e);

if (!document.getElementById("app")) {
  logError(new Error("app not found")); // causes unhandled rejection
  // Subsequent processing
}
@hagevvashi
hagevvashi / no-problem-ts-csf.ts
Last active April 13, 2020 03:11
TS × CSF group に対する指定だと問題ない
import React, { FC } from "react";
const MyComponent: FC = () => {
return (<div>foo</div>);
};
export default {
title: "title of group",
parameters: {
info: {
@hagevvashi
hagevvashi / problem-ts-csf.ts
Created April 13, 2020 03:11
TS × CSF パターンごと(個別)の設定上書きは問題あり
import React, { FC } from "react";
const MyComponent: FC = () => {
return (<div>foo</div>);
};
export default {
title: "title of group",
parameters: {
info: {
@hagevvashi
hagevvashi / csf-fc-diff.md
Created April 13, 2020 03:28
CSF FC diff
- export const Complicated: FC = () => <MyComponent />;
+ export const Complicated = () => <MyComponent />;