Tutorial by Examples: custome

import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { CommonModule } from '@angular/common'; import { AboutComponent } from './about.component'; @NgModule({ imports: [ CommonModule ], declarations: [ AboutComponent ], exports: [ AboutComponent ], schemas...
For Searching a place, we use the powerful element that Polymer ships, called google-map-search . All you need to do, is pass a map object and a query string to the element like so: <google-map-search map=[[map]] query=[[query]]></google-map-search> How do we pass the map ob...
If you want to provide Custom Error Messages you would do it like this: public class LoginViewModel { [Required(ErrorMessage = "Please specify an Email Address")] [EmailAddress(ErrorMessage = "Please specify a valid Email Address")] public string Email { get; set...
Create a new HTML tag named <hello-world> that will display "Hello, World!": <script> //define a class extending HTMLElement class HelloWorld extends HTMLElement { connectedCallback () { this.innerHTML = 'Hello, World!' } } //register the new custom elem...
Let's say that you have the following class: public class PersonInfo { public int ID { get; set; } [Display(Name = "First Name")] [Required(ErrorMessage = "Please enter your first name!")] public string FirstName{ get; set; } [Display(Name = "L...
Step 1: Creating Custom Error Logging Filter which will write Errors in Text Files According to DateWise. public class ErrorLogger : HandleErrorAttribute { public override void OnException(ExceptionContext filterContext) { string strLogText = ""; Excepti...
Sometimes it is required to implement Enum on your own. E.g. there is no clear way to extend other enums. Custom implementation allows this: class Enum { constructor(protected value: string) {} public toString() { return String(this.value); } public is(value: Enum | string) { ...
enum SourceEnum { value1 = <any>'value1', value2 = <any>'value2' } enum AdditionToSourceEnum { value3 = <any>'value3', value4 = <any>'value4' } // we need this type for TypeScript to resolve the types correctly type TestEnumType = SourceEnum | AdditionToS...
/** * requestdata - the data packet expected to be passed in by external system * JSON - data format exchange * stringify() convert javascript object into a string with JSON.stringify() * nlobjError - add in catch block to log exceptions */ function GetCustomerData(requestdata) { ...
Create enum of custom errors enum RegistrationError: Error { case invalidEmail case invalidPassword case invalidPhoneNumber } Create extension of RegistrationError to handle the Localized description. extension RegistrationError: LocalizedError { public var errorDescription...
SET FOREIGN_KEY_CHECKS=0; -- Customers TRUNCATE `customer_address_entity`; TRUNCATE `customer_address_entity_datetime`; TRUNCATE `customer_address_entity_decimal`; TRUNCATE `customer_address_entity_int`; TRUNCATE `customer_address_entity_text`; TRUNCATE `customer_address_entity_varchar`; T...
To illustrate this, here is a function that has 3 different "wrong" behaviors parameter is completely stupid: we use a user-defined expression parameter has a typo: we use Oracle standard NO_DATA_FOUND error another, but not handled case Feel free to adapt it to your standards: DE...
public function createCustomer($data , $token)//pass form data and token id { $customer=Customer::create(array( "email"=>$data['email'], "description" => $data['name'], "source" => $token // obtained with Stripe.js )); return $cus...
public function addCard($cust_id, $token) { $retriveResult=Customer::retrieve($cust_id); $tokendata = Token::retrieve($token); $newcard = $tokendata['card']; $flag = 1; foreach ($retriveResult['sources']['data'] as $card) { if($card['fingerprint'] === $newcard['f...
all errors and exceptions, both custom and default, are handled by the Handler class in app/Exceptions/Handler.php with the help of two methods. report() render() public function render($request, Exception $e) { //check if exception is an instance of ModelNotFoundException. if ($e in...
Sometimes you need to create your own Event, one that other plugins can listen to (Vault, among other plugins, does this) and even cancel. Bukkit's Event API allows this to be possible. All you need to do is make a new class, have it extend Event, add the handlers and the attributes your event needs...
To illustrate this, here is a function that has 3 different "wrong" behaviors the parameter is completely stupid: we use a user-defined expression the parameter has a typo: we use Oracle standard NO_DATA_FOUND error another, but not handled case Feel free to adapt it to your standa...
Sometimes you need to create your own Event, one that other plugins can listen to (Vault, among other plugins, does this) and even cancel. Bukkit's Event API allows this to be possible. All you need to do is make a new class, have it extend Event, add the handlers and the attributes your event needs...
creating custom exception 'P2222': create or replace function s164() returns void as $$ begin raise exception using message = 'S 164', detail = 'D 164', hint = 'H 164', errcode = 'P2222'; end; $$ language plpgsql ; creating custom exception not assigning errm: create or replace function s...
One of the features in SugarCRM 7.x is being able to easily add and extend custom endpoints to accomplish what you require. In this example, we'll create a couple of custom endpoints to return some data about the request. This custom file is being placed in custom/clients/base/api/DescriptionAPI.p...

Page 3 of 4