Skip to content

Instantly share code, notes, and snippets.

@esotrope
esotrope / ng-error-handling.ts
Last active August 10, 2017 01:15
Angular / API error handling
/*
This change is centered around noticing that we had our services mapping HTTP exception states to null which forced us to
(1) have null checking in each service object mapper and
(2) have null checks in our service subscription success handlers when they really belong in the error handler.
In this new approach we don't have to check for error cases in service subscription success handlers and mappers.
We let all exceptions propagate to
(1) Error resolve which can be displayed as a not found or generic error
(2) a service exception which can be displayed as a not found or generic error
@esotrope
esotrope / reporting-sql-strategy.sql
Created May 22, 2017 18:39
reporting sql strategy
-- Current path queries by endpoint:
-- /groups/{groupId}/latestassessment
-- gets latest assessment that a group took
select
e.completed_at,
a.id as assessment_id,
a.name as assessment_name,
a.grade_id as assessment_grade_id,
@esotrope
esotrope / gist:269a47a1315a6dd505cf8fb306489476
Last active November 20, 2021 14:41
autovalue vs lombok vs immutables syntax
/*
curl -X POST -H "Content-Type: application/json" -d '{"children":[{"id":"0"},{"id":"1"}],"childrenById":{"2":{"id":"2"}}}' http://localhost:8080/api/immutables
*/
@RestController
@RequestMapping("/api/lombok")
public class LombokController {
@RequestMapping(method = RequestMethod.GET)
public Parent get() {