appcd-response

2019-09-12

Library for responses and errors with i18n support and error codes.

appcd-response

Library for responses and errors with i18n support and error codes.

Visit https://github.com/appcelerator/appc-daemonfor more information.

Report issues to GitHub issues. Official issue tracker in JIRA.

Installation

npm i appcd-response

Usage

import Response from 'appcd-response';
import { codes } from 'appcd-response';

const msg1 = new Response('foo!');

const msg2 = new Response(codes.OK);

const msg3 = new Response(codes.OK, 'foo!');
import { AppcdError } from 'appcd-response';

throw new AppcdError(codes.BAD_REQUEST, 'Missing something important');
import { createErrorClass } from 'appcd-response';

const MyError = createErrorClass('MyError', {
    defaultStatus:     codes.BAD_REQUEST,
    defaultStatusCode: codes.PLUGIN_BAD_REQUEST
});

const err = new MyError('Something bad');
assert(err instanceof AppcdError);
assert(err instanceof Error);

Legal

This project is open source under the Apache Public License v2and is developed by Axway, Incand the community. Please read the LICENSEfile included in this distribution for more information.

HomePage

https://github.com/appcelerator/appc-daemon

Repository

https://github.com/appcelerator/appc-daemon/tree/master/packages/appcd-response


上一篇:winreglib
下一篇:appcd-request
相关教程
关注微信

扫码加入 JavaScript 社区

相关文章

首次访问,需要验证
微信扫码,关注即可
(仅需验证一次)

欢迎加入 JavaScript 社区

号内回复关键字:

回到顶部