How to use errorSource method in ava

Best JavaScript code snippet using ava

google-classroom-actions.js

Source:google-classroom-actions.js Github

copy

Full Screen

1import { google } from 'googleapis'2import util from './util.js'3import appSettings from '../config/config.js'4import chalk from 'chalk'5export default {6 async getStudentsForCourse (auth, courseId, index, total) {7 const classroom = google.classroom({ version: 'v1', auth })8 index = index || 09 total = total || 010 index = index + 111 const params = {12 courseId,13 pageSize: 10014 }15 await util.sleep(index * appSettings.taskDelay)16 console.log(`Fetching students for course: ${courseId} ${index} of ${total} tasks`)17 try {18 const res = await classroom.courses.students.list(params)19 const students = []20 if (Object.keys(res.data).length && res.data.students.length) {21 res.data.students.forEach(e => {22 students.push(e.profile.emailAddress)23 })24 }25 return { courseId, students }26 } catch (e) {27 console.log(e)28 const errorSource = 'getStudentsForCourse() CourseId: ' + courseId29 util.logError(errorSource, e.response.data.error.message)30 console.error(chalk.red(errorSource, e.response.data.error.message))31 }32 },33 async getTeachersForCourse (auth, courseId, index, total) {34 const classroom = google.classroom({ version: 'v1', auth })35 index = index || 036 total = total || 037 index = index + 138 const params = {39 courseId: courseId,40 pageSize: 10041 }42 await util.sleep(index * appSettings.taskDelay)43 console.log(chalk.whiteBright(`Fetching teachers for course: ${courseId} ${index} of ${total} tasks`))44 try {45 const res = await classroom.courses.teachers.list(params)46 const teachers = []47 if (Object.keys(res.data).length && res.data.teachers.length) {48 res.data.teachers.forEach(e => {49 teachers.push(e.profile.emailAddress)50 })51 }52 return { courseId, teachers }53 } catch (e) {54 const errorSource = 'getTeachersForCourse() CourseId: ' + courseId55 util.logError(errorSource, e.response.data.error.message)56 console.error(chalk.red(errorSource, e.response.data.error.message))57 }58 },59 async getCourse (auth, courseId) {60 const classroom = google.classroom({ version: 'v1', auth })61 const params = {62 id: courseId63 }64 try {65 const res = await classroom.courses.get(params)66 const course = res.data67 return course68 } catch (e) {69 const errorSource = 'getClassroomCourse() - CourseId: ' + courseId70 util.logError(errorSource, e.response.data.error.message)71 console.error(chalk.red(errorSource, e.response.data.error.message))72 }73 },74 async updateCourse (auth, courseAttributes, index, total) {75 const classroom = google.classroom({ version: 'v1', auth })76 index = index || 077 total = total || 078 index = index + 179 const id = courseAttributes.id80 const name = courseAttributes.name81 const section = courseAttributes.section82 const description = courseAttributes.description83 const descriptionHeading = courseAttributes.descriptionHeading84 const courseState = courseAttributes.courseState85 const params = {86 id,87 updateMask: 'name,section,description,descriptionHeading,courseState',88 requestBody: {89 name,90 section,91 description,92 descriptionHeading,93 courseState94 }95 }96 await util.sleep(index * appSettings.taskDelay)97 console.log(chalk.whiteBright(`Updating course attributes: ${id} ${index} of ${total} tasks`))98 try {99 const res = await classroom.courses.patch(params)100 const course = res.data101 console.log(chalk.greenBright(`[ Updating course: ${id} - Status: ${res.status} - ${res.statusText} ]\n`))102 return course103 } catch (e) {104 const errorSource = 'updateCourse() - CourseId: ' + id105 util.logError(errorSource, e.response.data.error.message)106 console.error(chalk.red(errorSource, e.response.data.error.message))107 }108 },109 async changeCourseState (auth, courseAttributes, index, total) {110 const classroom = google.classroom({ version: 'v1', auth })111 index = index || 0112 total = total || 0113 index = index + 1114 const id = courseAttributes.id115 const courseState = courseAttributes.courseState116 const params = {117 id,118 updateMask: 'courseState',119 requestBody: {120 courseState121 }122 }123 await util.sleep(index * appSettings.taskDelay)124 console.log(chalk.whiteBright(`Changing course state for course: ${id} to ${courseState} ${index} of ${total} tasks`))125 try {126 const res = await classroom.courses.patch(params)127 const course = res.data128 console.log(chalk.greenBright(`[ course: ${id} state: ${courseState} - Status: ${res.status} - ${res.statusText} ]`))129 return course130 } catch (e) {131 const errorSource = 'updateCourse() - CourseId: ' + id132 util.logError(errorSource, e.response.data.error.message)133 console.error(chalk.red(errorSource, e.response.data.error.message))134 }135 },136 async updateCourseNames (auth, courseAttributes, index, total) {137 const classroom = google.classroom({ version: 'v1', auth })138 index = index || 0139 total = total || 0140 index = index + 1141 const id = courseAttributes.id142 const name = courseAttributes.name143 const descriptionHeading = courseAttributes.descriptionHeading144 const params = {145 id,146 updateMask: 'name,descriptionHeading',147 requestBody: {148 name,149 descriptionHeading150 }151 }152 await util.sleep(index * appSettings.taskDelay)153 console.log(chalk.whiteBright(`Updating course name: ${id} ${index} of ${total}`))154 try {155 const res = await classroom.courses.patch(params)156 const course = res.data157 console.log(res.data)158 return course159 } catch (e) {160 const errorSource = 'changeCourseState() - CourseId: ' + id161 util.logError(errorSource, e.response.data.error.message)162 console.error(chalk.red(errorSource, e.response.data.error.message))163 }164 },165 async addTeacherToCourse (auth, courseId, teacher, index, total) {166 const classroom = google.classroom({ version: 'v1', auth })167 index = index || 0168 total = total || 0169 index = index + 1170 const params = {171 courseId,172 requestBody: { userId: teacher }173 }174 await util.sleep(index * appSettings.taskDelay)175 console.log(chalk.whiteBright(`Adding teacher to course: ${courseId} teacher: ${teacher} ${index} of ${total} tasks`))176 try {177 const res = await classroom.courses.teachers.create(params)178 console.log(chalk.greenBright(`[ ${courseId}/${teacher} - Status: ${res.status} - ${res.statusText} ]\n`))179 return res.data180 } catch (e) {181 const errorSource = `addTeacherToCourse() - CourseId: ${courseId} Teacher: ${teacher}`182 util.logError(errorSource, e.response.data.error.message)183 console.error(chalk.red(errorSource, e.response.data.error.message))184 }185 },186 async addStudentToCourse (auth, courseId, student, index, total) {187 const classroom = google.classroom({ version: 'v1', auth })188 index = index || 0189 total = total || 0190 index = index + 1191 const params = {192 courseId,193 requestBody: { userId: student }194 }195 await util.sleep(index * appSettings.taskDelay)196 console.log(chalk.whiteBright(`Adding student to course: ${courseId} student: ${student} ${index} of ${total} tasks`))197 try {198 const res = await classroom.courses.students.create(params)199 console.log(chalk.greenBright(`[ ${courseId} / ${student} - Status: ${res.status} - ${res.statusText} ]\n`))200 return res.data201 } catch (e) {202 const errorSource = `addStudentToCourse() - CourseId: ${courseId} StudentId: ${student}`203 util.logError(errorSource, e.response.data.error.message)204 console.error(chalk.red(errorSource, e.response.data.error.message))205 }206 },207 async removeStudentFromCourse (auth, courseId, student, index, total) {208 const classroom = google.classroom({ version: 'v1', auth })209 index = index || 0210 total = total || 0211 index = index + 1212 const params = {213 courseId,214 userId: student215 }216 await util.sleep(index * appSettings.taskDelay)217 console.log(chalk.whiteBright(`Removing student from course: ${courseId} student: ${student} ${index} of ${total} tasks`))218 try {219 const res = await classroom.courses.students.delete(params)220 console.log(chalk.greenBright(`[ ${courseId} / ${student} - Status: ${res.status} - ${res.statusText} ]\n`))221 return res.data222 } catch (e) {223 const errorSource = `removeStudentFromCourse() - CourseId: ${courseId} StudentId: ${student}`224 util.logError(errorSource, e.response.data.error.message)225 console.error(chalk.red(errorSource, e.response.data.error.message))226 }227 },228 async removeTeacherFromCourse (auth, courseId, teacher, index, total) {229 const classroom = google.classroom({ version: 'v1', auth })230 index = index || 0231 total = total || 0232 index = index + 1233 const params = {234 courseId,235 userId: teacher236 }237 await util.sleep(index * appSettings.taskDelay)238 console.log(chalk.whiteBright(`Removing teacher from course: ${courseId} teacher: ${teacher} ${index} of ${total} tasks`))239 try {240 const res = await classroom.courses.teachers.delete(params)241 console.log(chalk.greenBright(`[ ${courseId} / ${teacher} - Status: ${res.status} - ${res.statusText} ]\n`))242 return res.data243 } catch (e) {244 const errorSource = `removeTeacherFromCourse() - CourseId: ${courseId} Teacher: ${teacher}`245 util.logError(errorSource, e.response.data.error.message)246 console.error(chalk.red(errorSource, e.response.data.error.message))247 }248 },249 async createCourseAlias (auth, courseId, newAlias) {250 const classroom = google.classroom({ version: 'v1', auth })251 const params = {252 courseId,253 requestBody: {254 alias: newAlias255 }256 }257 try {258 const res = await classroom.courses.aliases.create(params)259 console.log(chalk.greenBright(`[ New Course Alias ${newAlias} - Status: ${res.status} - ${res.statusText} ]\n`))260 return res.data261 } catch (e) {262 const errorSource = 'createCourseAlias() - CourseId: ' + courseId263 util.logError(errorSource, e.response.data.error.message)264 console.error(chalk.red(errorSource, e.response.data.error.message))265 }266 },267 async getCourseAliases (auth, courseId, index, total) {268 const classroom = google.classroom({ version: 'v1', auth })269 index = index || 0270 total = total || 0271 index = index + 1272 await util.sleep(index * appSettings.taskDelay)273 console.log(chalk.white(`Fetching aliases for course: ${courseId} ${index} of ${total} tasks`))274 const aliases = []275 let nextPageToken = ''276 do {277 const params = {278 courseId,279 pageSize: 100,280 pageToken: nextPageToken || ''281 }282 try {283 const res = await classroom.courses.aliases.list(params)284 if (res.data.aliases && res.data.aliases.length) {285 res.data.aliases.forEach((e) => {286 aliases.push(e.alias)287 })288 }289 nextPageToken = res.data.nextPageToken290 } catch (e) {291 const errorSource = 'getCourseAliases() - CourseId: ' + courseId292 util.logError(errorSource, e)293 console.error(errorSource, e)294 }295 } while (nextPageToken)296 return {297 id: courseId,298 aliases299 }300 },301 async deleteCourseAlias (auth, courseId, alias) {302 const classroom = google.classroom({ version: 'v1', auth })303 const params = {304 courseId,305 alias306 }307 try {308 const res = await classroom.courses.aliases.delete(params)309 console.log(chalk.greenBright(`[ Delete Course Alias ${alias} - Status: ${res.status} - ${res.statusText} ]\n`))310 return res.data311 } catch (e) {312 const errorSource = 'deleteCourseAlias()'313 util.logError(errorSource, e.response.data.error.message)314 console.error(chalk.red(errorSource, e.response.data.error.message))315 }316 },317 async createCourse (store, auth, courseAttributes, index, total) {318 const classroom = google.classroom({ version: 'v1', auth })319 index = index || 0320 total = total || 0321 index = index + 1322 const params = {323 requestBody: {324 id: courseAttributes.id,325 ownerId: courseAttributes.ownerId,326 name: courseAttributes.name,327 section: courseAttributes.section,328 description: courseAttributes.description,329 descriptionHeading: courseAttributes.descriptionHeading,330 courseState: courseAttributes.courseState331 }332 }333 await util.sleep(appSettings.createTaskDelay)334 console.log(chalk.white(`Creating course: ${courseAttributes.id} ${index} of ${total} tasks`))335 try {336 const res = await classroom.courses.create(params)337 console.log(chalk.greenBright(`[ Create Course ${courseAttributes.id} - Status: ${res.status} - ${res.statusText} ]\n`))338 return res.data339 } catch (e) {340 store.isCoursesCreationError = true341 store.courseCreationTaskDelay = store.courseCreationTaskDelay * 2342 const errorSource = `createCourse() ${courseAttributes.id}`343 util.logError(errorSource, e.response.data.error.message)344 console.error(chalk.red(errorSource, e.response.data.error.message))345 }346 }...

Full Screen

Full Screen

VisualsContracts.nonmin.js

Source:VisualsContracts.nonmin.js Github

copy

Full Screen

1var powerbi;2!function(powerbi) {3 !function(VisualDataRoleKind) {4 VisualDataRoleKind[VisualDataRoleKind.Grouping = 0] = "Grouping", VisualDataRoleKind[VisualDataRoleKind.Measure = 1] = "Measure", 5 VisualDataRoleKind[VisualDataRoleKind.GroupingOrMeasure = 2] = "GroupingOrMeasure";6 }(powerbi.VisualDataRoleKind || (powerbi.VisualDataRoleKind = {}));7 powerbi.VisualDataRoleKind;8 !function(VisualDataChangeOperationKind) {9 VisualDataChangeOperationKind[VisualDataChangeOperationKind.Create = 0] = "Create", 10 VisualDataChangeOperationKind[VisualDataChangeOperationKind.Append = 1] = "Append";11 }(powerbi.VisualDataChangeOperationKind || (powerbi.VisualDataChangeOperationKind = {}));12 powerbi.VisualDataChangeOperationKind;13 !function(VisualUpdateType) {14 VisualUpdateType[VisualUpdateType.Data = 2] = "Data", VisualUpdateType[VisualUpdateType.Resize = 4] = "Resize", 15 VisualUpdateType[VisualUpdateType.ViewMode = 8] = "ViewMode", VisualUpdateType[VisualUpdateType.Style = 16] = "Style";16 }(powerbi.VisualUpdateType || (powerbi.VisualUpdateType = {}));17 powerbi.VisualUpdateType;18 !function(VisualPermissions) {}(powerbi.VisualPermissions || (powerbi.VisualPermissions = {}));19 var visuals;20 powerbi.VisualPermissions;21 !function(visuals) {22 var telemetry;23 !function(telemetry) {24 !function(ErrorSource) {25 ErrorSource[ErrorSource.PowerBI = 0] = "PowerBI", ErrorSource[ErrorSource.External = 1] = "External", 26 ErrorSource[ErrorSource.User = 2] = "User";27 }(telemetry.ErrorSource || (telemetry.ErrorSource = {}));28 telemetry.ErrorSource;29 }(telemetry = visuals.telemetry || (visuals.telemetry = {}));30 }(visuals = powerbi.visuals || (powerbi.visuals = {}));...

Full Screen

Full Screen

ui-error-message.js

Source:ui-error-message.js Github

copy

Full Screen

1import { bindable } from 'aurelia-framework';2export class UiErrorMessageCustomElement {3 @bindable errorSource;4 errorSourceChanged() {5 if (this.errorSource) {6 this.error = {};7 this.error.status = this.errorSource.status;8 this.error.statusText = this.errorSource.statusText;9 if ('bodyUsed' in this.errorSource && this.errorSource.bodyUsed === false) {10 this.errorSource.json().then(response => {11 if (response.message) {12 this.error.message = response.message;13 }14 })15 } else {16 if (this.errorSource.body && this.errorSource.body.message) {17 this.error.message = this.errorSource.body.message;18 }19 }20 } else {21 this.error = null;22 }23 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const test = require('ava');2const errorSource = require('error-source');3test('foo', t => {4 const err = new Error('bar');5 const source = errorSource(err);6 t.is(source, 'foo');7});8test('bar', t => {9 const err = new Error('foo');10 const source = errorSource(err);11 t.is(source, 'bar');12});

Full Screen

Using AI Code Generation

copy

Full Screen

1import test from 'ava';2import { errorSource } from 'ava/lib/test';3test('error source', t => {4 const error = new Error('foo');5 const source = errorSource(error);6 t.is(source.file, 'test.js');7 t.is(source.line, 4);8});9if (error.source) {10 const source = error.source;11 const filename = path.relative(process.cwd(), source.file);12 const line = source.line;13 const column = source.column;14 const prefix = chalk.gray(`${filename}:${line}:${column}`);15 output += `\n\n ${prefix}\n`;16}

Full Screen

Using AI Code Generation

copy

Full Screen

1var errorSource = require('./errorSource');2var errorSource = new errorSource();3var errorSource = errorSource.errorSource();4var errorSource = require('./errorSource');5var errorSource = new errorSource();6var errorSource = errorSource.errorSource();7var errorSource = require('./errorSource');8var errorSource = new errorSource();9var errorSource = errorSource.errorSource();10var errorSource = require('./errorSource');11var errorSource = new errorSource();12var errorSource = errorSource.errorSource();13var errorSource = require('./errorSource');14var errorSource = new errorSource();15var errorSource = errorSource.errorSource();16var errorSource = require('./errorSource');17var errorSource = new errorSource();18var errorSource = errorSource.errorSource();19var errorSource = require('./errorSource');20var errorSource = new errorSource();21var errorSource = errorSource.errorSource();22var errorSource = require('./errorSource');23var errorSource = new errorSource();24var errorSource = errorSource.errorSource();25var errorSource = require('./errorSource');26var errorSource = new errorSource();27var errorSource = errorSource.errorSource();28var errorSource = require('./errorSource');29var errorSource = new errorSource();30var errorSource = errorSource.errorSource();31var errorSource = require('./errorSource');32var errorSource = new errorSource();33var errorSource = errorSource.errorSource();34var errorSource = require('./errorSource');35var errorSource = new errorSource();36var errorSource = errorSource.errorSource();37var errorSource = require('./errorSource');38var errorSource = new errorSource();39var errorSource = errorSource.errorSource();

Full Screen

Using AI Code Generation

copy

Full Screen

1var errorSource = require('errorSource');2var error = new Error('Error Message');3var errorSourceName = errorSource.availableErrorSources(error);4console.log(errorSourceName);5var errorSource = require('errorSource');6var error = new Error('Error Message');7var errorSourceName = errorSource.availableErrorSources(error);8console.log(errorSourceName);9var errorSource = require('errorSource');10var error = new Error('Error Message');11var errorSourceName = errorSource.availableErrorSources(error);12console.log(errorSourceName);13var errorSource = require('errorSource');14var error = new Error('Error Message');15var errorSourceName = errorSource.availableErrorSources(error);16console.log(errorSourceName);17var errorSource = require('errorSource');18var error = new Error('Error Message');19var errorSourceName = errorSource.availableErrorSources(error);20console.log(errorSourceName);21var errorSource = require('errorSource');22var error = new Error('Error Message');23var errorSourceName = errorSource.availableErrorSources(error);24console.log(errorSourceName);25var errorSource = require('errorSource');

Full Screen

Using AI Code Generation

copy

Full Screen

1var errorSources = errorSource.availableErrorSources();2var errorSourceObj = errorSources.errorSource("MyErrorSource");3if (errorSourceObj != null)4{5 var errorSourceName = errorSourceObj.name();6 var errorSourceID = errorSourceObj.id();7 var errorSourceError = errorSourceObj.error();8 var errorSourceErrorID = errorSourceObj.errorID();9 var errorSourceErrorString = errorSourceObj.errorString();10 var errorSourceErrorDescription = errorSourceObj.errorDescription();11 var errorSourceErrorSolution = errorSourceObj.errorSolution();12}13{14}15var errorSourceObj = errorSource.errorSource("MyErrorSource");16if (errorSourceObj != null)17{18 var errorSourceName = errorSourceObj.name();19 var errorSourceID = errorSourceObj.id();20 var errorSourceError = errorSourceObj.error();21 var errorSourceErrorID = errorSourceObj.errorID();22 var errorSourceErrorString = errorSourceObj.errorString();23 var errorSourceErrorDescription = errorSourceObj.errorDescription();24 var errorSourceErrorSolution = errorSourceObj.errorSolution();25}26{27}28var errorSourceObj = errorSource.errorSource("MyErrorSource");29if (errorSourceObj != null)30{31 var errorSourceName = errorSourceObj.name();32 var errorSourceID = errorSourceObj.id();33 var errorSourceError = errorSourceObj.error();34 var errorSourceErrorID = errorSourceObj.errorID();35 var errorSourceErrorString = errorSourceObj.errorString();36 var errorSourceErrorDescription = errorSourceObj.errorDescription();37 var errorSourceErrorSolution = errorSourceObj.errorSolution();38}39{

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ava automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful