voluptasmollitia
Version:
Monorepo for the Firebase JavaScript SDK
79 lines (73 loc) • 3.3 kB
text/typescript
/**
* @license
* Copyright 2019 Google LLC
*
* 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.
*/
import { ErrorFactory } from '@firebase/util';
import { SERVICE, SERVICE_NAME } from '../constants';
export const enum ErrorCode {
TRACE_STARTED_BEFORE = 'trace started',
TRACE_STOPPED_BEFORE = 'trace stopped',
NONPOSITIVE_TRACE_START_TIME = 'nonpositive trace startTime',
NONPOSITIVE_TRACE_DURATION = 'nonpositive trace duration',
NO_WINDOW = 'no window',
NO_APP_ID = 'no app id',
NO_PROJECT_ID = 'no project id',
NO_API_KEY = 'no api key',
INVALID_CC_LOG = 'invalid cc log',
FB_NOT_DEFAULT = 'FB not default',
RC_NOT_OK = 'RC response not ok',
INVALID_ATTRIBUTE_NAME = 'invalid attribute name',
INVALID_ATTRIBUTE_VALUE = 'invalid attribute value',
INVALID_CUSTOM_METRIC_NAME = 'invalid custom metric name',
INVALID_STRING_MERGER_PARAMETER = 'invalid String merger input'
}
const ERROR_DESCRIPTION_MAP: { readonly [key in ErrorCode]: string } = {
[]: 'Trace {$traceName} was started before.',
[]: 'Trace {$traceName} is not running.',
[]:
'Trace {$traceName} startTime should be positive.',
[]:
'Trace {$traceName} duration should be positive.',
[]: 'Window is not available.',
[]: 'App id is not available.',
[]: 'Project id is not available.',
[]: 'Api key is not available.',
[]: 'Attempted to queue invalid cc event',
[]:
'Performance can only start when Firebase app instance is the default one.',
[]: 'RC response is not ok',
[]:
'Attribute name {$attributeName} is invalid.',
[]:
'Attribute value {$attributeValue} is invalid.',
[]:
'Custom metric name {$customMetricName} is invalid',
[]:
'Input for String merger is invalid, contact support team to resolve.'
};
interface ErrorParams {
[]: { traceName: string };
[]: { traceName: string };
[]: { traceName: string };
[]: { traceName: string };
[]: { attributeName: string };
[]: { attributeValue: string };
[]: { customMetricName: string };
}
export const ERROR_FACTORY = new ErrorFactory<ErrorCode, ErrorParams>(
SERVICE,
SERVICE_NAME,
ERROR_DESCRIPTION_MAP
);