- api_connection_error: Failure to connect to Stripe's API.
- api_error: API errors cover any other type of problem (e.g., a temporary problem with Stripe's servers), and are extremely uncommon.
- authentication_error: Failure to properly authenticate yourself in the request.
- card_error: Card errors are the most common type of error you should expect to handle. They result when the user enters a card that can't be charged for some reason.
- idempotency_error: Idempotency errors occur when an Idempotency-Key is re-used on a request that does not match the first request's API endpoint and parameters.
- invalid_request_error: Invalid request errors arise when your request has invalid parameters.
- rate_limit_error: Too many requests hit the API too quickly.
- validation_error: Errors triggered by our client-side libraries when failing to validate fields (e.g., when a card number or expiration date is invalid or incomplete).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case Failure(exception) => | |
exception match { | |
case e: CardException => | |
complete( | |
StatusCodes.PaymentRequired, | |
HttpEntity( | |
ContentTypes.`application/json`, | |
"{\"message\": \"Invalid card\", \"code\": \"" + e.declineCode + "\"}")) | |
case _ => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FakeService { | |
public class CustomCheckedException extends Throwable {} | |
public class CustomUncheckedException extends RuntimeException {} | |
public void doSomethingWithCheckedExceptions() throws CustomCheckedException { | |
throw new CustomCheckedException(); | |
} | |
public void doSomethingWithUncheckedExceptions() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
// Use Stripe's library to make requests... | |
} catch (CardException e) { | |
// Since it's a decline, CardException will be caught | |
System.out.println("Status is: " + e.getCode()); | |
System.out.println("Message is: " + e.getMessage()); | |
} catch (RateLimitException e) { | |
// Too many requests made to the API too quickly | |
} catch (InvalidRequestException e) { | |
// Invalid parameters were supplied to Stripe's API |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val route = | |
path("order") { | |
post { | |
entity(as[OrderRequest]) { orderRequest => | |
onComplete(PurchaseService.createPurchase(orderRequest)) { | |
case Success(result) => | |
complete(StatusCodes.Created, result) | |
case Failure(exception) => | |
system.log.error(exception, "Unexpected error") | |
complete(StatusCodes.InternalServerError, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p class="subtitle">Learn how one of the web’s biggest accidental success stories evolved.</p></header></div></div><div class="site-inner"><div class="content-sidebar-wrap"><main class="content"><article class="post-9674 page type-page status-publish entry"><div class="saboxplugin-wrap"><div class="saboxplugin-gravatar"><picture width="100" height="100" alt="Claire Broadley" class="avatar avatar-100 wp-user-avatar wp-user-avatar-100 alignnone photo sp-no-webp"><source srcset="https://digital.com/wp-content/uploads/AAEAAQAAAAAAAAkMAAAAJDIwMTM5ZDdiLTQwNTMtNDMxZS1iOGJlLWZlOGI1NzlhYzFlNg-150x150.webp" type="image/webp"><source srcset="https://digital.com/wp-content/uploads/AAEAAQAAAAAAAAkMAAAAJDIwMTM5ZDdiLTQwNTMtNDMxZS1iOGJlLWZlOGI1NzlhYzFlNg-150x150.jpg"><img src="https://digital.com/wp-content/uploads/AAEAAQAAAAAAAAkMAAAAJDIwMTM5ZDdiLTQwNTMtNDMxZS1iOGJlLWZlOGI1NzlhYzFlNg-150x150.jpg" width="100" height="100" alt="Claire Broadley" class="avatar avatar-100 wp-user-avatar wp-user-avatar-100 alignnone photo s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export CPPFLAGS="-I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include" | |
export LDFLAGS="-L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -Wl,-dead_strip_dylibs" | |
POSTGRES_EXTRA_CONFIGURE_OPTIONS="--with-uuid=e2fs --with-bonjour --with-openssl -v" asdf install postgres 9.6.10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
require 'pg' | |
require 'mysql2' | |
require 'sequel' | |
def get_db(database_name) | |
case database_name | |
when :pg | |
Sequel.connect('postgres://pierre:@localhost:5432/pierre') | |
when :mysql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let g:gist_post_private = 1 |
I hereby claim:
- I am pjambet on github.
- I am pierrej (https://keybase.io/pierrej) on keybase.
- I have a public key whose fingerprint is A7A2 1A00 1B8E BF41 1E54 7574 8DEF 6131 386B D257
To claim this, I am signing this object: