Skip to content

Instantly share code, notes, and snippets.

View rclayton-the-terrible's full-sized avatar

Richard Clayton rclayton-the-terrible

View GitHub Profile
const express = require('express');
const asyncRouter = require('../lib/async_router');
var router = asyncRouter(express.Router());
router.get('/', async (req, res, next) => {
// mkaing async errors
});
@lfalke
lfalke / StripeCardsSection.js
Last active August 1, 2024 17:22
Usage of react-stripe-elements with Material UI (v1.0) styling
import React, { PureComponent } from 'react'
import Grid from 'material-ui/Grid'
import { CardNumberElement, CardExpiryElement, CardCVCElement } from 'react-stripe-elements'
import StripeElementWrapper from './StripeElementWrapper'
export default class extends PureComponent {
static displayName = 'StripeCardsSection'
@rbramley
rbramley / CloudEvents-0.1.avsc
Created April 6, 2018 17:07
CloudEvents 0.1 Avro schema (draft)
{
"namespace": "CloudEvents",
"type": "record",
"name": "Event",
"fields": [
{"name": "cloudEventsVersion", "type": "string", "doc": "The version of the CloudEvents specification which the event uses. This enables the interpretation of the context."},
{"name": "eventType", "type": "string", "doc": "Type of the event data. Producers can specify the format of this, depending on their service. This enables the interpretation of data, and can be used for routing, policy and more."},
{"name": "eventTypeVersion", "type": ["null", "string"], "doc": "The version of the event-type. This enables the interpretation of data by eventual consumers, requires the consumer to be knowledgeable about the producer."},
{"name": "source", "type": "string", "doc": "This describes the event producer. Often this will include information such as the type of the event source, the organization publishing the event, and some unique idenfitiers. The exact syntax and semantics behind the data encoded in the URI is e

Hi, looks like this code fragment from your blog at: https://rclayton.silvrback.com/custom-errors-in-node-js

// I do something like this to wrap errors from other frameworks.
class InternalError extends DomainError {
  super(error.message);
  this.data = { error };
}

should be modified to have a constructor that takes that error from other frameworks like this?

@andywer
andywer / _readme.md
Last active January 8, 2025 04:42
React - Functional error boundaries

React - Functional error boundaries

Thanks to React hooks you have now happily turned all your classes into functional components.

Wait, all your components? Not quite. There is one thing that can still only be implemented using classes: Error boundaries.

There is just no functional equivalent for componentDidCatch and deriveStateFromError yet.

Proposed solution