Skip to content

Commit

Permalink
Merge 3e25a3b into 4ed8353
Browse files Browse the repository at this point in the history
  • Loading branch information
njgerner committed Aug 11, 2017
2 parents 4ed8353 + 3e25a3b commit 20a24cc
Show file tree
Hide file tree
Showing 13 changed files with 179 additions and 78 deletions.
61 changes: 61 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,64 @@ dist/

# Mac
.DS_Store


### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

.idea

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Node template
# Logs

# Runtime data

# Directory for instrumented libs generated by jscoverage/JSCover

# Coverage directory used by tools like istanbul

# nyc test coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)

# Bower dependency directory (https://bower.io/)

# node-waf configuration

# Compiled binary addons (http://nodejs.org/api/addons.html)

# Dependency directories

# Typescript v1 declaration files

# Optional npm cache directory

# Optional eslint cache

# Optional REPL history

# Output of 'npm pack'

# Yarn Integrity file

# dotenv environment variables file
132 changes: 66 additions & 66 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
{
"name": "@foundry-ai/api-errors",
"version": "0.1.1",
"description": "Common errors that can be thrown and caught reliably across services",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/FoundryAI/api-errors.git"
},
"homepage": "https://github.com/FoundryAI/api-errors#readme",
"keywords": [
"foundry",
"foundryai",
"foundry-api",
"foundryai-api",
"error",
"errors"
"name": "@foundry-ai/api-errors",
"version": "0.1.1",
"description": "Common errors that can be thrown and caught reliably across services",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/FoundryAI/api-errors.git"
},
"homepage": "https://github.com/FoundryAI/api-errors#readme",
"keywords": [
"foundry",
"foundryai",
"foundry-api",
"foundryai-api",
"error",
"errors"
],
"author": "FoundryAI Engineering",
"license": "MIT",
"bugs": {
"url": "https://github.com/FoundryAI/api-errors/issues"
},
"scripts": {
"build": "tsc -p ./",
"prepublishOnly": "tsc -p ./",
"reportCoverage": "nyc report --reporter=text-lcov | coveralls",
"run": "ts-node ./src/index.ts",
"test": "nyc mocha",
"watch": "mocha-typescript-watch"
},
"devDependencies": {
"@types/chai": "^4.0.1",
"@types/mocha": "^2.2.41",
"@types/node": "^8.0.19",
"chai": "^4.1.0",
"coveralls": "^2.13.1",
"mocha": "^3.5.0",
"mocha-typescript": "^1.1.7",
"nyc": "^11.1.0",
"source-map-support": "^0.4.15",
"supertest": "^3.0.0",
"ts-node": "^3.3.0",
"tslint": "^5.5.0",
"tslint-config-airbnb": "^5.2.1",
"typescript": "^2.4.2",
"typings": "^2.1.1"
},
"dependencies": {},
"nyc": {
"include": [
"src/**/*.ts"
],
"author": "FoundryAI Engineering",
"license": "MIT",
"bugs": {
"url": "https://github.com/FoundryAI/api-errors/issues"
},
"scripts": {
"build": "tsc -p ./",
"prepublishOnly": "tsc -p ./",
"reportCoverage": "nyc report --reporter=text-lcov | coveralls",
"run": "ts-node ./src/index.ts",
"test": "nyc mocha",
"watch": "mocha-typescript-watch"
},
"devDependencies": {
"@types/chai": "^4.0.1",
"@types/mocha": "^2.2.41",
"@types/node": "^8.0.19",
"chai": "^4.1.0",
"coveralls": "^2.13.1",
"mocha": "^3.5.0",
"mocha-typescript": "^1.1.7",
"nyc": "^11.1.0",
"source-map-support": "^0.4.15",
"supertest": "^3.0.0",
"ts-node": "^3.3.0",
"tslint": "^5.5.0",
"tslint-config-airbnb": "^5.2.1",
"typescript": "^2.4.2",
"typings": "^2.1.1"
},
"dependencies": {},
"nyc": {
"include": [
"src/**/*.ts"
],
"extension": [
".ts"
],
"require": [
"ts-node/register"
],
"reporter": [
"lcov",
"text-summary"
],
"sourceMap": true,
"instrument": true
}
}
"extension": [
".ts"
],
"require": [
"ts-node/register"
],
"reporter": [
"lcov",
"text-summary"
],
"sourceMap": true,
"instrument": true
}
}
14 changes: 14 additions & 0 deletions src/conflictError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { BaseError } from './baseError';

export class ConflictError extends BaseError {
constructor(message: string = 'Conflict', status: number = 409) {
// Calling parent constructor of base Error class.
super(message, status, 'conflict_error');

// Capturing stack trace, excluding constructor call from it.
Error.captureStackTrace(this, this.constructor);

// Saving class name in the property of our custom error as a shortcut.
this.name = this.constructor.name;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { suite, test } from 'mocha-typescript';
import { expect } from 'chai';

import { AuthenticationError } from './authenticationError';
import { AuthenticationError } from '../src/authenticationError';

@suite class AuthenticationErrorDefaults {
public error: AuthenticationError;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { suite, test } from 'mocha-typescript';
import { expect } from 'chai';

import { BadRequestError } from './badRequestError';
import { BadRequestError } from '../src/badRequestError';

@suite class BadRequestErrorDefaults {
public error: BadRequestError;
Expand Down
2 changes: 1 addition & 1 deletion src/baseError.spec.ts → test/baseError.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { suite, test } from 'mocha-typescript';
import { expect } from 'chai';

import { BaseError } from './baseError';
import { BaseError } from '../src/baseError';

@suite class BaseErrorDefaults {
public error: BaseError;
Expand Down
26 changes: 26 additions & 0 deletions test/conflictError.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { suite, test } from 'mocha-typescript';
import { expect } from 'chai';

import { ConflictError } from '../src/conflictError';

@suite class ConflictErrorDefaults {
public error: ConflictError;

before() { this.error = new ConflictError(); }

@test name() { expect(this.error.name).to.equal('ConflictError'); }
@test type() { expect(this.error.type).to.equal('conflict_error'); }
@test message() { expect(this.error.message).to.equal('Conflict'); }
@test status() { expect(this.error.status).to.equal(409); }
}

@suite class ConflictErrorCustom {
public error: ConflictError;

before() { this.error = new ConflictError('custom message', 999); }

@test name() { expect(this.error.name).to.equal('ConflictError'); }
@test type() { expect(this.error.type).to.equal('conflict_error'); }
@test message() { expect(this.error.message).to.equal('custom message'); }
@test status() { expect(this.error.status).to.equal(999); }
}
2 changes: 1 addition & 1 deletion src/forbiddenError.spec.ts → test/forbiddenError.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { suite, test } from 'mocha-typescript';
import { expect } from 'chai';

import { ForbiddenError } from './forbiddenError';
import { ForbiddenError } from '../src/forbiddenError';

@suite class ForbiddenErrorDefaults {
public error: ForbiddenError;
Expand Down
2 changes: 1 addition & 1 deletion src/internalError.spec.ts → test/internalError.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { suite, test } from 'mocha-typescript';
import { expect } from 'chai';

import { InternalError } from './internalError';
import { InternalError } from '../src/internalError';

@suite class InternalErrorDefaults {
public error: InternalError;
Expand Down
2 changes: 1 addition & 1 deletion test/mocha.opts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
--require source-map-support/register
--full-trace
--bail
src/**/*.spec.ts
test/**/*.spec.ts
2 changes: 1 addition & 1 deletion src/notFoundError.spec.ts → test/notFoundError.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { suite, test } from 'mocha-typescript';
import { expect } from 'chai';

import { NotFoundError } from './notFoundError';
import { NotFoundError } from '../src/notFoundError';

@suite class NotFoundErrorDefaults {
public error: NotFoundError;
Expand Down
2 changes: 1 addition & 1 deletion src/rateLimitError.spec.ts → test/rateLimitError.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { suite, test } from 'mocha-typescript';
import { expect } from 'chai';

import { RateLimitError } from './rateLimitError';
import { RateLimitError } from '../src/rateLimitError';

@suite class RateLimitErrorDefaults {
public error: RateLimitError;
Expand Down
8 changes: 4 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"target": "es6"
},
"include": [
"src/**/*.ts"
"src/**/*.ts",
"test/**/*.ts"
],
"exclude": [
"dist",
"node_modules",
"test/**/*.spec.ts"
"node_modules"
]
}
}

0 comments on commit 20a24cc

Please sign in to comment.