Skip to content

Commit

Permalink
Add error code mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
rickmak committed Jan 6, 2016
1 parent 818fd5c commit 274fbec
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import Pubsub from './pubsub';
import {RelationAction} from './relation';
import Geolocation from './geolocation';
import {Sequence} from './type';
import {AccessTokenNotAccepted} from './error';

var React;
if (typeof window !== 'undefined') {
Expand Down Expand Up @@ -320,7 +321,7 @@ export default class Container {

if (err) {
let skyErr = body.error || err;
if (skyErr.code === 104) {
if (skyErr.code === AccessTokenNotAccepted) {
return Promise.all([
container._setAccessToken(null),
container._setUser(null)
Expand Down
34 changes: 34 additions & 0 deletions lib/error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright 2015 Oursky Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const NotAuthenticated = 101;
export const PermissionDenied = 102;
export const AccessKeyNotAccepted = 103;
export const AccessTokenNotAccepted = 104;
export const InvalidCredentials = 105;
export const InvalidSignature = 106;
export const BadRequest = 107;
export const InvalidArgument = 108;
export const Duplicated = 109;
export const ResourceNotFound = 109;
export const NotSupported = 110;
export const NotImplemented = 111;
export const ConstraintViolated = 112;
export const IncompatibleSchema = 113;
export const AtomicOperationFailure = 114;
export const PartialOperationFailure = 115;
export const UndefinedOperation = 116;
export const PluginUnavailable = 117;
export const PluginTimeout = 118;

0 comments on commit 274fbec

Please sign in to comment.